currying
Thorsten
thorstenkiefer at gmx.de
Sat Mar 3 16:40:12 PST 2007
Hi, party people, because of my Haskell experience, I like the currying example of the online manual. I altered it a bit. How do you like this :
R delegate(X) Curry1(R,X,U...)(R delegate(U) dg,X arg)
{
struct Foo
{
typeof(dg) dg_m;
X arg_m;
R bar(U[1..$] args)
{
return dg_m(arg_m,args);
}
}
Foo* f = new Foo;
f.dg_m = dg;
f.arg_m = arg;
return &f.bar;
}
void main(char[][] args){
int plus(int a,int b){
return a + b;
}
auto b = Curry1(&plus,1);
writefln("%d",b(2));
}
Best Regards
Thorsten
More information about the Digitalmars-d
mailing list