reduce to pipeline

by Lucas Silva

JavaScript

function increment(input) { return input + 1;};
function decrement(input) { return input - 1;};
function double(input) { return input * 2; };
function halve(input) { return input / 2; };

let pipeline = [increment, double, decrement];

const result = pipeline.reduce(function(total, function) {
  return function(total);
}, 1);