www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13546] New: std.functional.not for arrays too

https://issues.dlang.org/show_bug.cgi?id=13546

          Issue ID: 13546
           Summary: std.functional.not for arrays too
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

I suggest std.functional.not to accept arrays too (and associative arrays) and
not just functions:

void main() {
    import std.stdio: writeln;
    import std.algorithm: filter;
    import std.functional: not;
    auto keys = [1, 2, 1, 1, 1, 2, 3];
    auto arr = [true, true, false, true];
    auto r1 = keys.filter!(k => !arr[k]);
    r1.writeln; // Output: [2, 2]
    auto r2 = keys.filter!(not!arr);
    r2.writeln;
}

--
Sep 27 2014