Skip to content

Instantly share code, notes, and snippets.

@godfat
Created May 16, 2010 14:56
Show Gist options
  • Save godfat/402911 to your computer and use it in GitHub Desktop.
Save godfat/402911 to your computer and use it in GitHub Desktop.
Function.prototype.curry = function(){
var slice = Array.prototype.slice,
args = slice.apply(arguments),
that = this
return function(){
var aa = args.concat(slice.apply(arguments))
if(that.arity == aa.length)
return that.apply(null, aa)
else
return Function.prototype.curry.apply(that, aa)
}
}
g = function(a, b, c){ print(a, b, c) }
f = g.curry()
f(1)(2)(3)
f(1,2)(3)
f(1)(2,3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment