Chapter 3Unifying Data with Sequences

Programs manipulate data. At the lowest level, programs work with structures such as strings, lists, vectors, maps, sets, and trees. At a higher level, these same data structure abstractions crop up again and again. For example:

  • XML data is a tree.
  • Database result sets can be viewed as lists or vectors.
  • Directory hierarchies are trees.
  • Files are often viewed as one big string or as a vector of lines.

In Clojure, all these data structures can be accessed through a single abstraction: the sequence (or seq).

A seq (pronounced “seek”) is a logical list. It’s logical because Clojure does not tie sequences to the concrete implementation details of the list data structure. Instead, the seq is an abstraction that ...

Get Programming Clojure, 3rd Edition 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.