Created
October 18, 2015 21:04
-
-
Save aztecrex/75ab4af15b1669c4ed24 to your computer and use it in GitHub Desktop.
Curry function, my answer to Omniscient.js Workshop task #13
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
var curry = function (fn) { | |
var me = this; | |
function gen(cur) { | |
return function () { | |
var next = cur.concat(Array.prototype.slice.call(arguments)) | |
if (next.length >= fn.length) { | |
return fn.apply(me, next) | |
} else { | |
return gen(next) | |
} | |
} | |
} | |
return gen([]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment