[Issue 8324] New: Arrays seen as callables for map/filter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 30 07:25:48 PDT 2012


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 at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at 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: -------


More information about the Digitalmars-d-bugs mailing list