JSFiddle - React, Tailwind, and code Playground

by Michaël van de Weerd

HTML

<output class="matrix" id="test">
  
</output>

JavaScript

class Matrix {
	constructor(shape) {
  	if (!(shape instanceof Array)) {
    	throw new Error("shape must be an array");
    }
    
    this.shape = [];
    
    for (let d in shape) {
    	if (d === 0) {
      	break;
      }
      
      this.shape.append(d);
    }
    
    if (this.shape.length === 0) {
    	throw new Error("shape must have at least one dimension");
    }
    
    this.data = new Set(this.shape[0]);
    
    let current = this.data, next;
    
    for (let i = 1; i < this.shape.length; i++) {
    	next = [];
      
      for (let s in current) {
      	let 
      }
    }
  }
}

let m = new Matrix([3, 5]);