Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 05, 2013 [Issue 9878] New: std.algorithm.cartesianProduct results order | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from bearophile_hugs@eml.cc 2013-04-04 19:48:53 PDT --- This is an example of Python usage of its product() function: >>> 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)] 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: ------- |
May 28, 2013 [Issue 9878] std.algorithm.cartesianProduct results order | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9878 --- Comment #1 from hsteoh@quickfur.ath.cx 2013-05-27 19:56:52 PDT --- 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 28, 2013 [Issue 9878] std.algorithm.cartesianProduct results order | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9878 thelastmammoth@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |thelastmammoth@gmail.com --- Comment #2 from thelastmammoth@gmail.com 2013-05-27 21:28:17 PDT --- (In reply to comment #1) > https://github.com/D-Programming-Language/phobos/pull/1314 Please 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 28, 2013 [Issue 9878] std.algorithm.cartesianProduct results order | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=9878 --- Comment #3 from bearophile_hugs@eml.cc 2013-05-28 02:56:25 PDT --- (In reply to comment #2) > where 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: ------- |
Copyright © 1999-2021 by the D Language Foundation