Accessing Collections
The purpose of our collections is to store our data, but they’re only useful if we can get the data back out of the collection. Let’s first consider the collections that support indexed lookup by a key.
Indexed Access
Maps and vectors are the two indexed collections provided in Clojure. Vectors use 0-based indexes and are treated as associative collections from index to element. The records that we saw while modeling our domain also implement the map interfaces and can be treated as indexed collections.
Indexed collections support lookup by three methods. The first is by invoking the get function with the collection and a key. The second is by invoking the collection itself with a key. The third is by invoking a keyword ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access