Multiple range enumeration

puming via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 10 18:38:17 PST 2015


Hi,

If I have multiple ranges, say:

auto a = [1, 2, 3];
auto b = ["a", "b", "c"];
auto c = ["x", "y", "z"];

I'd like a composition range that enumerate all combinations of 
these ranges,
having the same effect as a nested foreach loop:

foreach (i; a) {
   foreach (j; b) {
     foreach (k; c) {
        writlen(i, j, k);
     }
   }
}

Is there such a generic function in std lib?


More information about the Digitalmars-d-learn mailing list