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: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@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: -------

Reply via email to