On Wed, Dec 14, 2011 at 21:14, Justin Whear <[email protected]> wrote: > 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") ] > ));
I needed something like that a year or so ago. You can find it under the name 'combinations' : http://svn.dsource.org/projects/dranges/trunk/dranges/docs/algorithm.html Philippe
