a callable object whose opCall takes at least 1 object
A single parameter callable object
//works with callable structs too struct S { int w; int opCall(int x, int y, int z) { return w + x + y + z; } } S s; s.w = 5; auto cs = curry(s); auto cs1 = cs(1); auto cs2 = cs(2); assert(cs1(2)(3) == s(1, 2, 3)); assert(cs1(2)(3) == (1 + 2 + 3 + 5)); assert(cs2(2)(3) ==s(2, 2, 3));
int f(int x, int y, int z) { return x + y + z; } auto cf = curry!f; auto cf1 = cf(1); auto cf2 = cf(2); assert(cf1(2)(3) == f(1, 2, 3)); assert(cf2(2)(3) == f(2, 2, 3));
Takes a function of (potentially) many arguments, and returns a function taking one argument and returns a callable taking the rest. f(x, y) == curry(f)(x)(y)