Bug 13546 – std.functional.not for arrays too

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-09-27T21:27:30Z
Last change time
2017-09-05T12:13:16Z
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-09-27T21:27:30Z
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; }
Comment #1 by razvan.nitu1305 — 2017-09-05T12:09:21Z
This seems like a corner case for arrays. Its implementation would lead to more problems than cases where things get simplified. If you want to work with boolean arrays you could either use the solution in the bug report or you could always use BitArrays. Also there is the problem of where should the function `not` be located after this change, because all the functions in std.functional work solely with functions. In my opinion, this should be closed as WONTFIX.