www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13684] New: std.numeric.isRectangular

https://issues.dlang.org/show_bug.cgi?id=13684

          Issue ID: 13684
           Summary: std.numeric.isRectangular
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

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);

--
Nov 04 2014