O'Reilly logo

Clojure Applied by Alex Miller, Ben Vandgrift

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parallelism with Reducers

Most data manipulation in Clojure is specified in terms of functions applied over sequences. Sequences (by their definition) are logical lists of values in some order. Most of the core library sequence functions are applied lazily, in order, and on a single thread. As you might guess in a chapter about using your cores, that last detail is a problem.

Reducers are an alternative way to express transformations over sequential data and feel similar to sequence function composition. However, reducers can execute those transformations in parallel using fork/join.

From Sequences to Reducers

Let’s consider a concrete example. A shipping company has data about all of the products that it needs to ship right now. Each product ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required