Created
January 28, 2019 13:43
-
-
Save SanichKotikov/1f108ed55863e903d90cde00b562ae52 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 add1 = (v) => v + 1; | |
const mul2 = (v) => v * 2; | |
const div3 = (v) => v / 3; | |
const compose = (fn1, fn2) => (...args) => fn1(fn2(...args)); | |
const mapper = [div3, mul2, add1].reduce(compose); | |
const result = [2, 5, 8, 11, 14, 17, 20].map(mapper); | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment