fork(1) download
  1. import std.stdio;
  2.  
  3. class carry(TResult, TParams...) {
  4. public this(TResult delegate(TParams) _f) {
  5. f = _f;
  6. }
  7. public auto opCall(TParams[0] para) {
  8. static if (TParams.length > 1) {
  9. return new carry!(TResult, TParams[1 .. $])( (TParams[1 .. $] args) { return f(para, args); } );
  10. } else {
  11. return f(para);
  12. }
  13. }
  14. public TResult delegate(TParams) f;
  15. }
  16.  
  17. void main() {
  18. auto f = new carry!(int, int, int, int, int)( (int a, int b, int c, int d) { return a+b+c+d; } );
  19. writeln(f(1)(2)(3)(4));
  20. }
Success #stdin #stdout 0.01s 2120KB
stdin
Standard input is empty
stdout
10