get the shape of a 2d array as a 2-tuple describing the major-axis's length, and the minor-axis's length.
import { assertEquals } from "jsr:@std/assert"const arr2d: Array2DRowMajor<number> = [ [1 , 2 , 3 , 4 , 5 ], [6 , 7 , 8 , 9 , 10], [11, 12, 13, 14, 15],]const [rows, cols] = shapeOfArray2D(arr2d)assertEquals(rows, 3)assertEquals(cols, 5) Copy
import { assertEquals } from "jsr:@std/assert"const arr2d: Array2DRowMajor<number> = [ [1 , 2 , 3 , 4 , 5 ], [6 , 7 , 8 , 9 , 10], [11, 12, 13, 14, 15],]const [rows, cols] = shapeOfArray2D(arr2d)assertEquals(rows, 3)assertEquals(cols, 5)
get the shape of a 2d array as a 2-tuple describing the major-axis's length, and the minor-axis's length.
Example