Transducers
Before we finish up with our core.async
portion of this book, we should mention what came up in Clojure 1.7, as well as how this affects core.async
.
One of the big changes in this release was the introduction of transducers
. We will not cover the nuts and bolts of it here, but rather focus on what it means at a high-level with examples using both Clojure sequences and core.async
channels.
If you would like to know more, I recommend Carin Meier's Green Eggs and Transducers blog post[4]. It's a great place to start.
Additionally, the official Clojure documentation site on the subject is another useful resource[5].
Let's get started by creating a new Leiningen project:
$ lein new core-async-transducers
Now, open your project.clj
file and make sure you have the right dependencies:
...
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/core.async "0.4.474"]]
...
Next, fire up a REPL session in the project root and require core.async
, which we will be using...