August 2015
Intermediate to advanced
220 pages
5h 53m
English
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.
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 ...