Specific collection types in Clojure

Now that you know about Clojure's general collection properties and the sequence abstraction, it is a good time to get to know about Clojure's specific collection implementations.

Vectors

Vectors are Clojure's workhorse; together with map, it is the most used collection. Don't be afraid of them; they have nothing to do with Java's java.util.Vector. They are just a series of ordered values, such as a list or an array.

They have the following properties:

  • They are immutable
  • They can be accessed sequentially
  • They are associative (they are maps of their indices, meaning that their keys are 0, 1, 2, and so on)
  • They are counted, meaning they have a finite size
  • They have random access, so you can access any element with almost ...

Get Clojure: High Performance JVM Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.