Re: Switching rows with columns

2015-07-05 Thread via Digitalmars-d-learn
On Sunday, 5 July 2015 at 00:18:18 UTC, Tanel Tagaväli wrote: On Saturday, 4 July 2015 at 16:29:44 UTC, Marc Schütz wrote: Try std.range.transposed: http://dlang.org/phobos/std_range.html#.transposed Does this work with user-defined types? I defined two structs that implement the

Re: Switching rows with columns

2015-07-05 Thread via Digitalmars-d-learn
On Sunday, 5 July 2015 at 11:35:14 UTC, Marc Schütz wrote: Maybe it's the last condition, `hasAssignableElements`. I don't know whether that one is really necessary... It probably is. The last check returned false. Since I already would have to implement r.front = , I'll just use arrays.

Switching rows with columns

2015-07-04 Thread via Digitalmars-d-learn
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?

Re: Switching rows with columns

2015-07-04 Thread via Digitalmars-d-learn
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

Re: Switching rows with columns

2015-07-04 Thread via Digitalmars-d-learn
On Saturday, 4 July 2015 at 16:29:44 UTC, Marc Schütz wrote: Try std.range.transposed: http://dlang.org/phobos/std_range.html#.transposed Does this work with user-defined types? I defined two structs that implement the InputRange(possibly ForwardRange) interface, an integer range and a range