Last active
February 4, 2022 04:16
-
-
Save LesleyLai/ef1fc28d858fbfb43af4a3d51a6314a8 to your computer and use it in GitHub Desktop.
C++ currying implementation by Ben Deane
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename Callable, typename... Params> | |
auto curry(Callable f, Params... ps) | |
{ | |
if constexpr (requires { f(ps...); }) { | |
return f(ps...); | |
} else { | |
return [f, ps...] (auto... qs) | |
{ | |
return curry(f, ps..., qs...); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment