digitalmars.D.learn - Zip with range of ranges
- ARaspiK (3/3) Feb 25 2018 Instead of passing std.range.zip a set of ranges as different
- Paul Backus (11/14) Feb 25 2018 `std.range.transposed` does this, but it requires that the range
- ARaspiK (3/17) Feb 25 2018 Thank you so much. It works now. I was already receiving a
Instead of passing std.range.zip a set of ranges as different arguments, is it possible to hand the m a range of ranges, and get them to zip together each element of every subrange?
Feb 25 2018
On Sunday, 25 February 2018 at 16:22:19 UTC, ARaspiK wrote:Instead of passing std.range.zip a set of ranges as different arguments, is it possible to hand the m a range of ranges, and get them to zip together each element of every subrange?`std.range.transposed` does this, but it requires that the range of ranges has assignable elements, so it may not work in all cases. For example: import std.range; import std.algorithm.iteration; import std.stdio; auto rr1 = [[1, 2, 3], [4, 5, 6]]; rr1.transposed.each!writeln; // Works auto rr2 = only(only(1, 2, 3), only(4, 5, 6)); rr2.transposed.each!writeln; // Doesn't work
Feb 25 2018
On Sunday, 25 February 2018 at 20:18:27 UTC, Paul Backus wrote:On Sunday, 25 February 2018 at 16:22:19 UTC, ARaspiK wrote:Thank you so much. It works now. I was already receiving a forward range, so copying was easy.Instead of passing std.range.zip a set of ranges as different arguments, is it possible to hand the m a range of ranges, and get them to zip together each element of every subrange?`std.range.transposed` does this, but it requires that the range of ranges has assignable elements, so it may not work in all cases. For example: import std.range; import std.algorithm.iteration; import std.stdio; auto rr1 = [[1, 2, 3], [4, 5, 6]]; rr1.transposed.each!writeln; // Works auto rr2 = only(only(1, 2, 3), only(4, 5, 6)); rr2.transposed.each!writeln; // Doesn't work
Feb 25 2018