foreach change for multi-dimensional data

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 28 07:38:20 PST 2016


On 01/28/2016 05:33 AM, ixid wrote:
 > This is an idle thought hence putting it on the Learn-level forum. An
 > idea struck me for foreach to make working with more complicated data
 > types or heavily nested data easier.
 >
 >
 >      uint[][] a = [[1,2,3],[4,5,6]];

[...]

 > It would be nice if you could do something like this:
 >
 >      foreach(uint c; a)
 >          c.writeln;

It looks like Solomon E's recent collapse() is what we need here:

   http://forum.dlang.org/post/xihlsfgfpykdvmvrggyr@forum.dlang.org

     foreach(c; a.collapse)
         // ...

Ali



More information about the Digitalmars-d-learn mailing list