Hacker News new | past | comments | ask | show | jobs | submit login

C++14 version: https://dpaste.de/a8g9D/

You obviously can't pass this to C code, but it's a portable and extremely efficient solution if you are working purely within a C++ code-base.




I don't think "curry" is quite the right name for that function. For a function

    int f(int, int, int);
the curried version of f,

    auto f_curried = curry(f);
must be able to take multiple arguments one-at-a-time, so

    f_curried(x)(y)(z) == f(x, y, z)
The code at https://dpaste.de/a8g9D/ just partially applies the function to one set of arguments, which isn't enough -- you have to keep partially applying until you get them all.


I knew I should have just called it bind.

As a bonus, an actual implementation of curry: https://dpaste.de/qGWcq/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: