Skip to content

Instantly share code, notes, and snippets.

@paolobueno
Last active September 25, 2018 12:31
Show Gist options
  • Save paolobueno/f5b439dcd8b7968d374ad6cc553f31e1 to your computer and use it in GitHub Desktop.
Save paolobueno/f5b439dcd8b7968d374ad6cc553f31e1 to your computer and use it in GitHub Desktop.
Simple variadic compose
const apply = (x, fn) => fn(x);
const c = (...fns) => {
[first, ...rest] = fns.reverse();
return x => rest.reduce(apply, first(x));
}
const add = x => y => x + y;
c(add(1), add(4))(3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment