array of delegates
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Apr 13 23:27:29 PDT 2016
On 04/13/2016 04:39 PM, Alex wrote:
> import std.algorithm;
> indarr.map!(a => partial!(sg, a));
I think you want to generate a different delegate for each element where
the first argument to sg is the value of that element (0, 1, etc.).
Since the second element of sg is a Props, you then want to call those
delegates with a Props value (e.g. Props.p1).
The following works:
import std.algorithm;
auto mapped = indarr
.map!(a => (Props p) => sg(a, p))
.map!(d => d(Props.p1));
writeln(mapped);
Ali
More information about the Digitalmars-d-learn
mailing list