Skip to content

Instantly share code, notes, and snippets.

@Zshazz
Created Feb 28, 2013
Embed
What would you like to do?
import std.stdio, std.range, std.typecons, std.algorithm;
void main() {
auto a = iota(5);
auto b = repeat(1).take(3);
auto c = [5,9,30];
auto tup = tuple(a,b,c);
foreach(e; tupWrapper(tup).nWayUnion())
writeln(e);
}
auto tupWrapper(Tup)(Tup tup) {
alias E = ElementType!(Tup.Types[0]);
InputRange!E[] arr;
foreach(T; Tup.Types)
static assert(is(ElementType!T == E));
foreach(ref e; tup)
arr ~= inputRangeObject(e);
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment