3 ms·
C++14 version: https://dpaste.de/a8g9D/ https://dpaste.de/a8g9D/ You obviously can't pass this to C code, but it's a portable and extremely efficient solution
by mihai_ionic 13y ago
C++14 version: https://dpaste.de/a8g9D/ 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.
- panic 13y agoI 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/ 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.
- mihai_ionic 13y agoI knew I should have just called it bind. As a bonus, an actual implementation of curry: https://dpaste.de/qGWcq/ https://dpaste.de/qGWcq/