ZeviLiao
8/25/2018 - 4:56 AM

Compose function test

Compose js test

const compose = (...fns) =>
  fns.reduceRight(
    (prevFn, nextFn) => (...args) => nextFn(prevFn(...args)),
    value => value
  );

const addone = a => a + 1;
const mult = a => a * a;

console.log(
  compose(
    mult,
    addone,
    addone
  )(1)
); //9

//https://gist.github.com/JamieMason/172460a36a0eaef24233e6edb2706f83