Skip to main content

Working with Sequences

beginner

The Sequence Abstraction

Clojure's sequence abstraction provides a uniform interface for working with collections.

Common Operations

Transforming with map

map applies a function to every element:

(map inc [1 2 3])
;; => (2 3 4)

Filtering

filter selects elements matching a predicate:

(filter even? (range 10))
;; => (0 2 4 6 8)

Lazy Evaluation

Sequences are lazy by default — elements are computed only when needed.