std.algorithm.map with multiple lambdas (2.066.0-b1) (does not compile)
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 5 12:31:22 PDT 2014
This is an instance of these bugs:
https://issues.dlang.org/show_bug.cgi?id=5710
https://issues.dlang.org/show_bug.cgi?id=11946
But seeing that `map` works with a single lambda/local function,
it should be possible to make it work with several ones too.
For the time being, a simple workaround is to make the local
functions static:
void main() {
static int square(int i) { return i*i; }
static int twoTimes(int i) { return i+i; }
import std.algorithm, std.stdio;
auto arr = [1,2,3];
arr.map!(twoTimes, square).writeln;
}
More information about the Digitalmars-d-learn
mailing list