Bug 12842 – More support for ranges of ranges

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-02T13:22:02Z
Last change time
2024-12-01T16:21:20Z
Assigned to
No Owner
Creator
John Colvin
Moved to GitHub: phobos#9634 →

Comments

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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9634 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB