Skip to content

Instantly share code, notes, and snippets.

@djtriptych
Last active August 29, 2015 14:10
Show Gist options
  • Save djtriptych/7260910a5b32a572cfad to your computer and use it in GitHub Desktop.
Save djtriptych/7260910a5b32a572cfad to your computer and use it in GitHub Desktop.
Javascript autocurry
var autocurry = function (f) {
return function () {
var args = Array.prototype.slice.call(arguments, 0);
return args.length < f.length ?
autocurry(args.reduce(function (g, arg) {return g.bind(null, arg)}, f)) :
f.apply(null, args);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment