[Issue 7128] Cartesian product of ranges

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 5 18:06:05 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=7128



--- Comment #3 from bearophile_hugs at eml.cc 2013-02-05 18:06:03 PST ---
Partially implemented:

http://forum.dlang.org/thread/510f29fd574fd_2193e77ae82545b@sh2.rs.github.com.mail


Currently three or more arguments are not accepted:

import std.stdio, std.algorithm;
void main() {
    cartesianProduct([0,1], [0,1], [0,1]).writeln();
}


Another interesting feature of Python itertools.product() that's missing is the
optional "repeat" argument:

>>> from itertools import product
>>> list(product([0,1], repeat=3))
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0),
(1, 1, 1)]
>>>
>>> list(product([0,1], repeat=4))
[(0, 0, 0, 0), (0, 0, 0, 1), (0, 0, 1, 0), (0, 0, 1, 1), (0, 1, 0, 0), (0, 1,
0, 1), (0, 1, 1, 0), (0, 1, 1, 1
), (1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1,
0, 1), (1, 1, 1, 0), (1, 1, 1,
 1)]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list