Skip to content

Instantly share code, notes, and snippets.

@lantosgyuri
Created May 29, 2020 13:42
Show Gist options
  • Save lantosgyuri/60e9e4daa309a2d4b3906cb53ce4ed7e to your computer and use it in GitHub Desktop.
Save lantosgyuri/60e9e4daa309a2d4b3906cb53ce4ed7e to your computer and use it in GitHub Desktop.
const createAdder = (base) => (secondary) => secondary + base;
const numbers = [1,2,3,4,5];
const fns = numbers.map(item => createAdder(item));
const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x);
const addAll = pipe(...fns);
// console.log(addAll(6));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment