I know I’m getting boring with currying, but I have finished most of what I originally wanted. And I am publishing the code this time. It is published under GPL.

Now, a curried function can be invoked with a single call, like a regular function; in two calls; or in as many calls as you wish - the only limit is the actual number of arguments. So, all of the following works:

f(1, 2, 3, 4, 5, 6)
f(1, 2, 3, 4, 5)(6)
f(1, 2, 3, 4)(5)(6)
f(1, 2)(3)(4)(5, 6)

On reddit, a very nice explanation of currying by m42a contained this piece of code:

template <class Func>
auto partially_apply_to_2(Func f)
    return uncurry(curry(f)(2));

It returns a new function that is same as f, but with the first argument set to 2. (see the post why this is more practical than std::bind). With the new version of curry.h, you don’t even need to uncurry the function, you can just do this:

return curry(f)(2);
// or:
return curry(f, c);

Here are a few documented examples of what you can do:


And here is the header file: curry/curry.h

{% gist 6269914 %}