Joseph Rushton Wakeling:

If I use zip() to collate together one or more ranges, the individual elements
get returned as a Tuple of the corresponding types.

Is there any way to get zip to label those elements, i.e. to return e.g.

See:
http://d.puremagic.com/issues/show_bug.cgi?id=8715

I think currently you have to use map!() to replace the tuple. Maybe am unsafe map-cast suffices:

import std.stdio, std.range, std.algorithm, std.typecons;

void main() {
    auto r1 = zip(["red", "blue"], [10, 20]);
    r1.writeln;
    alias T2 = Tuple!(string,"col", int,"val");
    r1.map!(r => T2(r[])).writeln;
    r1.map!(r => cast(T2)r).writeln;
}

Bye,
bearophile

Reply via email to