O'Reilly logo

The Joy of Clojure, Second Edition by Michael Fogus and Chris Houser

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Collection types

It’s better to have 100 functions operate on one data structure than 10 functions on 10 data structures.

Alan Perlis[1]

1 “Epigrams on Programming,” ACM SIGPLAN 17, no. 9 (September 1982).

This chapter covers

  • Persistence, sequences, and complexity
  • Vectors: creating and using them in all their varieties
  • Lists: Clojure’s code form data structure
  • How to use persistent queues
  • Persistent sets
  • Thinking in maps
  • Finding the position of items in a sequence

Clojure provides a rich set of composite data types, or collection types, and we’ll cover them all: vectors, lists, queues, sets, and maps. In this chapter, we’ll dig into the strengths and weaknesses of each. We’ll spend more time on vectors and maps than ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required