Created
October 5, 2018 15:34
-
-
Save pre1ude/59665508925c959c9fc94ce8de1a8ca3 to your computer and use it in GitHub Desktop.
just as named
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 | |
? curry(f.bind(undefined, ...args)) | |
: f(...args) | |
// : f(...args.slice(0, f.length)) | |
const add = (a, b, c) => a + b + c | |
const cAdd = curry(add) | |
cAdd(1,2,3)//6 | |
cAdd(1)(2,3)//6 | |
cAdd(1)(2)(3)//6 | |
cAdd(1,2)(3)//6 |
Author
pre1ude
commented
Oct 5, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment