June 30, 2012 [Issue 8324] New: Arrays seen as callables for map/filter | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8324 Summary: Arrays seen as callables for map/filter Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2012-06-30 07:28:23 PDT --- A low-priority enhancement request. In some cases the mapping function is just an array or associative array: import std.stdio, std.range, std.algorithm; void main() { auto a = [0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1]; iota(0, a.length).filter!(i => a[i])().writeln(); } Output: [1, 4, 9, 16] So maybe filter/map (and few other higher order functions) can be improved (using a new little function in std.functional) to see a given array/associative array as a callable: iota(0, a.length).filter!a().writeln(); The Clojure language supports something similar. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
June 30, 2012 [Issue 8324] Arrays seen as callables for map/filter | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=8324 timon.gehr@gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timon.gehr@gmx.ch --- Comment #1 from timon.gehr@gmx.ch 2012-06-30 07:39:39 PDT --- Also see issue 6110. -- 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