digitalmars.D.bugs - [Issue 9878] New: std.algorithm.cartesianProduct results order
- d-bugmail puremagic.com (40/42) Apr 04 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9878
- d-bugmail puremagic.com (6/6) May 27 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9878
- d-bugmail puremagic.com (14/15) May 27 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9878
- d-bugmail puremagic.com (9/11) May 28 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9878
http://d.puremagic.com/issues/show_bug.cgi?id=9878 Summary: std.algorithm.cartesianProduct results order Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: minor Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc This is an example of Python usage of its product() function:[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)] This is a similar usage of Phobos std.algorithm.cartesianProduct: import std.stdio, std.algorithm, std.string, std.conv, std.array; void main() { auto bits = [0, 1]; auto p = cartesianProduct(bits, bits, bits); p.text.replace("Tuple!(int, int, int)", "").writeln; } Its output: [(0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), (0, 0, 1), (1, 0, 1), (0, 1, 1), (1, 1, 1)] I'd like cartesianProduct() to give its results in the same order as Python. If you see in Python the results are like the binary numbers: 000 001 010 011 100 101 110 111 I think this is a more natural and more useful order. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------from itertools import product list(product([0, 1], repeat=3))
Apr 04 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9878 https://github.com/D-Programming-Language/phobos/pull/1314 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 27 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9878 thelastmammoth gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thelastmammoth gmail.comhttps://github.com/D-Programming-Language/phobos/pull/1314Please see: http://forum.dlang.org/post/mailman.283.1369715080.13711.digitalmars-d puremagic.com where I suggest to give a template parameter to specify lexicographic/antilexicographic, along with depth first/breadth first. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 27 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9878where I suggest to give a template parameter to specify lexicographic/antilexicographic, along with depth first/breadth first.If you want to add an option to specify the ordering, then I'd like the order discussed here (lexicographic) to be the default one, because it's the most commonly needed by me, and it's what I expect when I port Python code to D. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 28 2013