I gave a talk at London’s Clojure eXchange 2015 on the subject of parallel folds using Clojure’s transducers.
From the programme:
Sharing experience gained from his work on a mission-critical data product earlier this year, Henry will speak about some newer features of Clojure that enable data scientists to write concise, expressive and performant data processing code. He’ll explore transducers and reducing functions, and show how simple functional combinators can make even sophisticated analytical code both faster and easier to comprehend.
The key takeaway is that with transducers, reducing functions must now provide an arity-1 completer implementation which provides them with the opportunity to convert an accumulated value into a final output. Together with the (optional) arity-0 initializer this provides reducing functions the ability to wrap arbitrarily intricate state. The natural composability of transducers can be mirrored with similarly composable reducing functions to build up sophisticated parallel computations.