Comment #0 by john.loughran.colvin — 2014-06-02T13:22:02Z
std.range and std.algorithm often have support for an arbitrary number of ranges passed as seperate parameters, but very few offer range-of-range support.
Usage example:
auto a = [1,2,3,4];
auto b = [5,6,7,8,9];
//a rectangular matrix in flat form
auto cp = cartesianProduct(a, b).map!"a[0] * b[0]"();
//expand to RoR, take the transform and return to flat
auto cpT = cp.chunks(a.length).roundRobin().joiner();
Currently that doesn't work as roundRobin doesn't know how to handle ranges of ranges.
Comment #1 by john.loughran.colvin — 2014-06-02T13:24:58Z
sorry, ignore the .joiner()
Comment #2 by dhasenan — 2017-12-03T16:41:38Z
This bit me today with cartesianProduct. I'd naively expect to be able to do something like:
iota(3).map!(x => iota(1, 7)).cartesianProduct
to get all possible results for rolling three six-sided dice. Unfortunately, I had to write my own implementation of cartesianProduct to make it work.
Comment #3 by robert.schadek — 2024-12-01T16:21:20Z