Skip to content

Instantly share code, notes, and snippets.

@ksnabb
Last active January 19, 2019 16:32
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 ksnabb/a023f3643c50cfdc6d272a0e738d1106 to your computer and use it in GitHub Desktop.
Save ksnabb/a023f3643c50cfdc6d272a0e738d1106 to your computer and use it in GitHub Desktop.
function compose(f, g) {
return function (A) {
return g(f(A));
}
}
const compose = (...fns) => fns.reduce((g, f) => (...args) => f(g(...args)));
@ksnabb
Copy link
Author

ksnabb commented Jan 17, 2019

here is a more useful version:

const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment