Skip to content

Instantly share code, notes, and snippets.

@javascripter
Created December 19, 2008 21:15
Show Gist options
  • Save javascripter/38123 to your computer and use it in GitHub Desktop.
Save javascripter/38123 to your computer and use it in GitHub Desktop.
var functools = {
partial: function (fun, thisObject) {
var args = Array.slice(arguments, 2);
return function () {
Array.prototype.unshift.apply(arguments, args);
return fun.apply(thisObject, arguments);
}
},
compose: function () {
var args = arguments;
return function (val) {
return Array.reduceRight(args, function (val, f) {
return f(val);
}, val)
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment