Last active
May 28, 2016 07:26
-
-
Save trygvea/bacf40043be9f48ff7048e6c6503eaaa to your computer and use it in GitHub Desktop.
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
const curry = f => (...args) => | |
args.length >= f.length | |
? f(...args) | |
: (...more) => curry(f)(...args, ...more) | |
// Test it. If | |
const f = (a,b,c) => a+b+c | |
const g = curry(f) | |
// then the following holds true: | |
f(1,2,3) === 6 && | |
g(1,2,3) === 6 && | |
g(1)(2)(3) === 6 && | |
g(1)(2,3) === 6 && | |
g(1,2)(3) === 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment