Set operation like cartesian product

Andrea Fontana nospam at example.com
Thu Feb 28 07:31:59 PST 2013


I see cartesianProduct in std.algorithm. I read:

auto N = sequence!"n"(0); // the range of natural numbers
auto N2 = cartesianProduct(N, N); // the range of all pairs of 
natural numbers

So it gives (0,0) (0,1) (1,0) ... and so on.

Is there a way to generate only tuple:

a[0] > a[1] (0,1) (0,2) ... (1,2) (1,3) .. (2,3) (2,4)

or

a[0] >= a[1] (0,0) (0,1) (0,2) ... (1,1) (1,2) (1,3) .. (2,2) 
(2,3) (2,4)

Or the only way is use filter!(...) after cartesianProduct?


More information about the Digitalmars-d-learn mailing list