Skip to content

Instantly share code, notes, and snippets.

@jasonbellamy
Created October 18, 2016 02:36
Show Gist options
  • Save jasonbellamy/1efcbc26c300fb6697e46916eeca15a6 to your computer and use it in GitHub Desktop.
Save jasonbellamy/1efcbc26c300fb6697e46916eeca15a6 to your computer and use it in GitHub Desktop.
2 different implementations of compose
const compose = (...rest) => (
(z) => rest.reverse().reduce((x, y) => y(x), z)
);
const compose2 = (fn, ...rest) => (
(rest.length === 0) ? fn :(z) => compose2(...rest)(fn(z))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment