Skip to content

Instantly share code, notes, and snippets.

@SanichKotikov
Created January 28, 2019 13:43
Show Gist options
  • Save SanichKotikov/1f108ed55863e903d90cde00b562ae52 to your computer and use it in GitHub Desktop.
Save SanichKotikov/1f108ed55863e903d90cde00b562ae52 to your computer and use it in GitHub Desktop.
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