Created
April 1, 2019 10:09
-
-
Save andiwinata/6a873f3398944c51d389c5db1fc8a93b to your computer and use it in GitHub Desktop.
Implementation of curry is es6
This file contains hidden or 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
// Curry is only taking 1 parameter different from partial application | |
curry = fn => { | |
const self = params => arg => { | |
const nextParams = [...params, arg] | |
if (nextParams.length === fn.length) return fn(...nextParams); | |
return self(nextParams); | |
} | |
return self([]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment