Skip to content

Instantly share code, notes, and snippets.

@elclanrs
Created August 31, 2014 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elclanrs/95f0fbe365089259b232 to your computer and use it in GitHub Desktop.
Save elclanrs/95f0fbe365089259b232 to your computer and use it in GitHub Desktop.
var toArray = Array.call.bind([].slice)
var curryN = function(n, f, as) {
return function() {
var bs = (as||[]).concat(toArray(arguments))
return bs.length < n ? curryN(n, f, bs) : f.apply(null, bs)
}
}
var curry = function(f) {
return function() {
var as = toArray(arguments)
return f.length > as.length ? curryN(f.length, f, as) : f.apply(null, as)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment