InUsing iterators to write highly composeable code, we saw that thestaged approachto data transformation is decomposed, but duplicates the entire data set. Whereas, thesingle pass approachis more efficient, but the code was entangled and monolithic.Now we’re going to look at an interesting approach for building composeable pipelines of transformations without incurring a memory penalty,transducers.Let’s start with a review of reducing (a/k/a “folding”):reducersAreduceris a function that takes an accumulation and a value, and folds the value into the accumulation. For example, if[1, 2, 3]is an
...
继续阅读
(22)