language: D (dmd) (dmd-2.042)
date: 328 days 22 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import std.stdio;
 
class carry(TResult, TParams...) {
        public this(TResult delegate(TParams) _f) {
                f = _f;
        }
        public auto opCall(TParams[0] para) {
                static if (TParams.length > 1) {
                        return new carry!(TResult, TParams[1 .. $])( (TParams[1 .. $] args) { return f(para, args); } );
                } else {
                        return f(para);
                }
        } 
        public TResult delegate(TParams) f;
}
 
void main() {
        auto f = new carry!(int, int, int, int, int)( (int a, int b, int c, int d) { return a+b+c+d; } );
        writeln(f(1)(2)(3)(4));
}