Comment #0 by bearophile_hugs — 2014-11-04T11:04:11Z
I suggest to add to Phobos a simple function of common use, "isRectangular". Given a nD (2D, 3D, etc) array it verifies that the matrix is a "rectangular" nD box, with all rows of the same length, etc.
So:
assert(isRectangular([[1, 2], [3, 4]]) == true);
assert(isRectangular([[1, 2], [3]]) == false);
assert(isRectangular([[[1, 2], [3, 4]]]) == true);
assert(isRectangular([[[1, 2], [3, 4]], []]) == false);
Comment #3 by razvan.nitu1305 — 2021-07-29T07:27:21Z
Closing as per kinke's comment:
"I don't think Phobos needs such a function; it may encourage people to think jagged arrays (arrays of arrays) are a reasonable way to represent such rectangular multidimensional arrays, while we have a much better suited library for that: http://mir-algorithm.libmir.org/mir_ndslice.html
Using join() for the recursion and thus requiring potentially huge temporary buffers for such a check is bad."