Last active
August 4, 2016 19:37
-
-
Save VadimBrodsky/9160294f154da0666306d66d996abeee to your computer and use it in GitHub Desktop.
Implementing the Curry function in JavaScript for arbitrary number of arguments
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
| function curry(func) { | |
| var slice = Array.prototype.slice, | |
| args = slice.call(arguments, 1); | |
| return function () { | |
| return func.apply( | |
| null, | |
| args.concat(slice.call(arguments, 0)) | |
| ); | |
| }; | |
| } |
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
| function curry(func, ...first) { | |
| return function (...second) { | |
| return func(...first, ...second); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment