Skip to content

Instantly share code, notes, and snippets.

@dolohow
Created June 9, 2016 17:59
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 dolohow/edbc0337c050ed5def46c19d8ef73e9d to your computer and use it in GitHub Desktop.
Save dolohow/edbc0337c050ed5def46c19d8ef73e9d to your computer and use it in GitHub Desktop.
function add(x, y) {
return x + y;
}
function mul(x, y) {
return x * y;
}
function make(arg) {
var arr = [];
arr.push(arg);
return function f(x) {
if (typeof x === 'number') {
arr.push(x);
return f;
}
return exec(x);
}
function exec(x) {
return arr.reduce(x);
}
}
var s = make(1)(2)(3)(4)(5);
console.log(s(add));
console.log(s(mul));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment