© 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 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.