how to return map(fn)
Ali Çehreli
acehreli at yahoo.com
Tue Feb 22 18:03:10 UTC 2022
On 2/22/22 05:53, steve wrote:
> What I was trying
> to return is function that can then be applied to e.g. an array.
I think an eponymous template that defines an alias as in your original
post can be used as well:
template mappified(alias func) {
import std.algorithm : map;
alias mappified = map!func;
}
void main() {
import std.stdio;
writeln([1,2].mappified!(a => a * 10));
}
There is std.functional which includes function composition tools:
https://dlang.org/phobos/std_functional.html
Ali
More information about the Digitalmars-d-learn
mailing list