Part 3. Part 3. Data structures

 

This part of the book is dedicated to the functions operating on data structures, which usually involves one or more collections used as argument. Data structures and the functions operating on them, are a fundamental part of Clojure (as well as other programming languages). The book uses the term data structure to identify a container for data and to distinguish them from "scalars" or "singletons", which are atomic data that cannot be divided any further.

Clojure implements many types of data structures and also interoperates well with those provided by Java. Clojure data structures are usually immutable and persistent (there are exceptions that are well marked thanks to strong conventions). When a data structure is "mutated" in Clojure, it produces what appears to be new one, but internally they share most of the data. For all practical purposes, clients of the data structure don’t need to know if there is structural sharing or how it works, as Clojure takes care of all the implementation details.

The functions operating on data structures have been broadly categorized as follows: