Bug 13684 – std.numeric.isRectangular

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-11-04T11:04:11Z
Last change time
2021-07-29T07:27:21Z
Keywords
pull, trivial
Assigned to
No Owner
Creator
bearophile_hugs

Comments

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 #1 by bugzilla — 2021-02-07T12:04:57Z
Note: std.range:transposed can do these checks.
Comment #2 by dlang-bot — 2021-07-25T12:19:00Z
@lucica28 updated dlang/phobos pull request #8175 "[DSSv3] Fix Issue 13684 - std.numeric.isRectangular" fixing this issue: - Fix issue 13684 https://github.com/dlang/phobos/pull/8175
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."