Compose Functions with Reduce

Share this video with your friends

Send Tweet

Javascript has first-class functions which means that any function can stored, passed around, and returned just like an Object can. This allows for a lot of flexibility with how you call functions. This allows us to use array reduction to create functional pipelines by composing arrays of functions.

Andreas
Andreas
~ 9 years ago

Cool! Seems like there is either a problem with the jsBin link or the code is missing

dan entous
dan entous
~ 8 years ago

excellent explanation. one possible improvement to get across the transition from the initial program to the composition program: have the transform function use the initial program’s functions instead of hardcoding the math in it; e.g. return decrement( double( increment( input ) ) );