Created
May 9, 2013 14:04
-
-
Save CatTail/5547620 to your computer and use it in GitHub Desktop.
Curry and uncurry
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.prototype.uncurryThis = function() { | |
| var f = this; | |
| return function() { | |
| var a = arguments, b = [].slice.call(a, 1); | |
| return f.apply(a[0], b); | |
| }; | |
| }; | |
| Function.prototype.curry = function() { | |
| var fn = this; | |
| var args = [].slice.call(arguments, 0); | |
| return function() { | |
| return fn.apply(this, args.concat([].slice.call(arguments, 0))); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment