[Issue 6004] std.range.unzip()

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 25 13:39:26 PDT 2017


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

--- Comment #6 from Andrei Alexandrescu <andrei at erdani.com> ---
(In reply to Seb from comment #5)
> > For forward ranges of tuples "unzip" can be implemented in a few lines. E.g.
> 
> That's pretty sweet! I actually built something on top of this and was about
> to submit it:
> 
> https://github.com/dlang/phobos/compare/master...wilzbach:unzip
> 
> But then I realized that std.range.transversal already solves this nicely:
> 
> import std.algorithm, std.range, std.stdio;
> int[][] x = new int[][3];
> x[0] = [1, 2, 3];
> x[1] = [4, 5, 6];
> x.transversal(1).writeln; // [2, 5]
> x.front.walkLength.iota.map!(i => transversal(x, i)).writeln; // [[1, 4],
> [2, 5], [3, 6]]
> 
> Plat with this online: https://is.gd/YYCgPk
> 
> So I'm inclined to close this as WORKSFORME - other opionions?

Seb, could you please copy the example you wrote in transversal? Also mention
the feature can be found in other languages with the name "unzip", thus making
the term searchable. It would close this bug. Thanks!

--


More information about the Digitalmars-d-bugs mailing list