Created
November 13, 2018 13:00
-
-
Save dcollien/6f4f21f1d023cd4e6657a8b19771c215 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 uncurry = (fn) => (...args) => args.reduce((fn, arg) => fn(arg), fn); | |
const curry = (fn) => { | |
const collect = (args, arg) => { | |
const collected = args.concat([arg]); | |
return ( | |
collected.length >= fn.length | |
? fn.apply(null, collected) | |
: collect.bind(null, collected) | |
); | |
}; | |
return collect.bind(null, []); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment