A persistent list is Clojure’s immutable, singly linked list. The list function creates a clojure.lang.PersistentList from zero or more arguments, including nil; with no arguments it returns the empty list. Lists are central to Clojure code and functional arguments, but vectors, sets, maps, and lazy sequences are often more flexible for everyday collection work. section 9.4.1
Understand its behavior through the operations that make lists useful:
- Links elements into a chain, with each newly added element at the head; the empty list uses a specialized EmptyList tail. section 9.4.1
- Uses conj to add at the head, so repeated additions print in reverse insertion order. section 9.4.1
- Supports peek and pop, making it a natural last-in-first-out stack. section 9.4.1
- Provides the concrete result of reverse: a persistent list containing the input items in reverse order. section 8.3.8
- Requires sequential input for reverse and throws IllegalArgumentException for values without a sequential version. section 8.3.8
Head insertion and reversal
(-> () (conj 1) (conj 2) (conj 3)) ;; (3 2 1) (defn rev [coll] (into () coll)) (rev (range 10)) ;; (9 8 7 6 5 4 3 2 1 0) Because into repeatedly applies conj, inserting into an empty list reverses the source collection. section 9.4.1
A stack for nearest-smaller values
A list can hold values that are pushed and removed from the head while processing a sequence. The nearest-smaller algorithm pushes each input value, pops larger candidates, and peeks at the nearest remaining smaller value. For [0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15], it returns (0 0 4 0 2 2 6 0 1 1 5 1 3 3 7 7). section 9.4.1
Figure 9.6. A list formed from a chain of PersistentList objects. The EmptyList is a specialized version of PersistentList to handle the tail position.
Inspect the linked chain of PersistentList objects and the specialized EmptyList tail. section 9.4.1

