Skip to content

Instantly share code, notes, and snippets.

@eliperelman
Created September 13, 2012 21:48
Show Gist options
  • Save eliperelman/3717939 to your computer and use it in GitHub Desktop.
Save eliperelman/3717939 to your computer and use it in GitHub Desktop.
Recursive function composition
var compose = function () {
var args = arguments;
return function () {
var funcs = [].slice.call(args);
return (function x(value) {
var current = funcs.pop();
return current ? x(current(value)) : value;
})(funcs.pop().apply(this, arguments));
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment