Clojure's built in data structures
So far, we've dealt with discrete pieces of data: one number, one string, one value. When programming, it is more often the case that you want to work with groups of data. Clojure has great facilities for working with these groups, or collections, of data. Not only does it provide four different types of data strucutres, but it also provides a uniform way to use all of these data structures together.
- Lists - a linked list, sequential access
- Vectors - an indexed array
- Maps - key-value pair (hash map)
- Sets - a unique set of values
- Immutable - once a data structure is defined it cannot be changed.
- Persistent - changes to data structures are created in a new data structure which is linked back to the original data structure
- Shared memory - copies create during a change to a data structure share memory for the common elements
- Dynamically typed - contains any value, including functions (as they evaluate to a value)