Cartesian product of ranges?

Justin Whear justin at economicmodeling.com
Wed Dec 14 12:14:11 PST 2011


I've looked through std.algorithm and std.range, but haven't found anything 
to compute the Cartesian product of several ranges. I have the nagging 
feeling that this can be accomplished by combining several of the range 
transformations in the standard library.

What I'm after is something like this:

alias Tuple!(int, string) P;
assert(equal( 
	cartesianProduct([1, 2], ["a", "b"]),
	[ P(1, "a"), P(1, "b"), P(2, "a"), P(2, "b") ]
));



More information about the Digitalmars-d-learn mailing list