chapter eleven
Maps, along with sequences and vectors, are possibly the most flexible and used Clojure data structures. They support Clojure application design in several ways:
- Attaching "names" to data that semantically belong together. Each key in a map is a name for a value.
- Supporting immutability and persistency in a performance effective way (map uses the same HAMT Hash Array Mapped Trie data structure used by vectors [170]).
- Allowing lookup by key, including using the map itself as a function.
- The standard library contains many functions dedicated to map manipulation (such as “assoc, assoc-in and dissoc”, merge, select-keys, etc.). The description of such functions is the topic of this chapter.
Clojure contains several kind of maps which are often described using a mix of constructors names and actual Java types. The following are concrete implementations inheriting from a common clojure.lang.IPersistentMap interface: