------------------
And I'd like map/filter to accept arrays and associative
arrays, and not just functions:
void main() {
import std.algorithm: map;
auto keys = [1, 2, 1, 1, 1];
auto a = [0, 10, 20];
auto r1 = map!(k => a[k])(keys); // OK
auto r2 = map!a(keys); // Error
auto aa = [1: 10, 2: 20];
auto r3 = map!(k => aa[k])(keys); // OK
auto r4 = map!aa(keys); // Error
}
This is a common idiom in Clojure. Arrays and associative
arrays can be seen as functions defined by an enumeration of
input-outputs.
This part of ER 8715 is coming from quickfur:
https://github.com/D-Programming-Language/phobos/pull/2556
Bye,
bearophile