© Mark McDonnell 2017

Mark McDonnell, Quick Clojure, https://doi.org/10.1007/978-1-4842-2952-1_4

4. Sequences

Mark McDonnell

(1)southend-on-Sea, UK

In Clojure we have many types of collections: lists, vectors, maps, and sets. Each of these collections is also a sequence. Clojure provides an interface that is known as the sequence abstraction, and it is this abstraction that allows multiple types of built-in functions to work uniformly across these different collection types.

Before we get into the sequence abstraction, let’s start with a task that is common when programming in Clojure, which is the need to loop over a collection in order to carry out some form of side effect. Consider the following example (Listing 4-1), where we loop over a list ...

Get Quick Clojure: Effective Functional Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.