Created
September 12, 2020 12:11
-
-
Save lilywang711/b4fcc260646dc7b76e7b4ebac9046987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compose = (...fns) => (input) => fns.reverse().reduce((acc, fn) => fn(acc), input); | |
const addOne = (x) => x + 1; | |
const square = (x) => x * x; | |
console.log(compose(addOne, square)(2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment