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

Updating Collections

Our applications are in constant communication with the external world, receiving new information, updating existing information, and removing information that’s no longer relevant. However, this seems at odds with Clojure’s immutable core collections.

In Clojure, change is always modeled as the application of a pure function to an immutable value, resulting in a new immutable value. We’ll use the simple word update to describe this means of change so as to avoid linguistic gymnastics.

Defining collections with immutability has many advantages. First, concurrent threads can pass around values, rather than references to values. This ensures that data isn’t modified unpredictably by other threads. Second, we separate our ...

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