Reducers are a new abstraction introduced in Clojure 1.5 and are likely to have a wider impact on the rest of the Clojure implementation in future versions. They depict a different way of thinking about processing collections in Clojure—the key concept is to break down the notion that collections can be processed only sequentially, or only lazily, or only producing a seq, and so on. Moving away from such behavior guarantee raises the potential for eager and parallel operations on one hand while incurring constraints on the other hand. Reducers are compatible with the existing collections.
For an example, an observation of the regular map
function reveals that its classic definition is tied to the mechanism (recursion), order (sequential), laziness (often), and representation (list/seq/other) aspects of producing the result. Most of this actually defines "how" the operation is performed rather than "what" needs to be done. In the case of map
, the "what" is all about...