Switching rows with columns
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 4 09:29:41 PDT 2015
On Saturday, 4 July 2015 at 15:28:56 UTC, Tanel Tagaväli wrote:
> I have a range of ranges and need to change it so the elements
> are column-aligned instead of row-aligned.
>
> For example,
> [[1, 2, 3],
> [4, 5, 6],
> [7, 8, 9]]
> would change into
> [[1, 4, 7],
> [2, 5, 8],
> [3, 6, 0]].
>
> Can I even do this with ranges, and if so, how?
Try std.range.transposed:
http://dlang.org/phobos/std_range.html#.transposed
More information about the Digitalmars-d-learn
mailing list