digitalmars.D.bugs - [Issue 5075] New: std.algorithm.map/filter don't support associative arrays or their byKey()/byValue()
- d-bugmail puremagic.com (42/49) Oct 18 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5075
- d-bugmail puremagic.com (10/10) Oct 18 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5075
- d-bugmail puremagic.com (7/8) Oct 18 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5075
- d-bugmail puremagic.com (9/9) Oct 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5075
- d-bugmail puremagic.com (7/7) Oct 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5075
- d-bugmail puremagic.com (20/20) Jan 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5075
- d-bugmail puremagic.com (8/8) Dec 06 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5075
- d-bugmail puremagic.com (13/13) Mar 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=5075
http://d.puremagic.com/issues/show_bug.cgi?id=5075 Summary: std.algorithm.map/filter don't support associative arrays or their byKey()/byValue() Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc This is a small interactive REPL with Python 2.6:[-1, -2, -3, -4]data = {1:4, 2:3, 3:1, 4:0} map(lambda x: -x, data)[3, 4]filter(lambda x: x > 2, data)[-1, -2, -3, -4]from itertools import imap, ifilter list(imap(lambda x: -x, data))[3, 4] 'data' is an associative array, and "lambda" is used to define local anonymous functions. But map and filter in current Phobos with DMD 2.049 don't seem to support associative arrays as inputs: import std.algorithm: map, filter; void main() { int[int] data = [1:4, 2:3, 3:1, 4:0]; auto r1 = map!((int x) { return -x; })(data); auto r2 = filter!((int x) { return x > 2; })(data); } Nor byKey()/byValue(): import std.algorithm: map, filter; void main() { int[int] data = [1:4, 2:3, 3:1, 4:0]; auto r1 = map!((int x) { return -x; })(data.byKey()); auto r2 = filter!((int x) { return x > 2; })(data.byKey()); auto r3 = map!((int x) { return -x; })(data.byValue()); auto r4 = filter!((int x) { return x > 2; })(data.byValue()); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------list(ifilter(lambda x: x > 2, data))
Oct 18 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5075 kennytm gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kennytm gmail.com See issue 4067. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 18 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5075See issue 4067.I mean issue 4607 :|. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 18 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5075 Andrei Alexandrescu <andrei metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5075 So the second part of this bug report (about byKey()/byValue()) is a dupe. The first part is an enhancement request that I think is not duplicated. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5075 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|std.algorithm.map/filter |std.algorithm.map/filter |don't support associative |don't support associative |arrays or their |arrays |byKey()/byValue() | After fixing issue 4607 this doesn't work still: import std.algorithm: map, filter; void main() { int[int] data = [1:4, 2:3, 3:1, 4:0]; auto r1 = map!(x => -x)(data); auto r2 = filter!(x => x > 2)(data); } Also restricted the name of this issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 17 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5075 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 06 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5075 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WONTFIX Given the current design of Phobos, I think this enhancement request will not be fulfilled. A future associativeArray.byPair that yields 2-tuples is a better solution. So I close this down. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 30 2013