Created
August 8, 2019 07:16
-
-
Save jossmac/89e5b12aed6765d126eac6ed10b07c48 to your computer and use it in GitHub Desktop.
Fixing a number of arguments to a function, producing another function of smaller arity
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 partialApply = (fn, ...fixedArgs) => { | |
return (...remainingArgs) => fn(...fixedArgs.concat(...remainingArgs)); | |
}; | |
const add = (a, b) => a + b; | |
const add10 = partialApply(add, 10); | |
console.log(add10(5)) // 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment