Returns the final element of a sequenceable collection, or nil when no element is available. It accepts one collection argument, including nil or an empty sequence. section 3.5.1
Use last with collections that implement the sequence interface:
- Ordered sequences return their final element: (last '(1 2 3 4)) produces 4. section 3.5.1
- nil and empty sequences return nil rather than raising an exception. section 3.5.1
- Maps yield key-value pairs and sets yield elements, but unordered collections do not provide a predictable insertion-based final element. section 3.5.1
Basic use
(def numbers '(1 2 3 4)) (last numbers) ;; 4 (last nil) ;; nil section 3.5.1
Listing 3.25. → Sequence processing, Iteration
(first [xs]) (second [xs]) (last [xs])
Browse the related sequence-access signatures for first, second, and last. section 3.5.1
