The Sequence Functions

Sequences = lists and vectors (including strings). One set of functions works on all of them, with keyword arguments :test, :key, :start, :end, :from-end, and :count.

(length "hello")                               ; 5
(elt '(a b c) 1)                               ; B
(subseq #(1 2 3 4 5) 1 3)                      ; #(2 3)
(copy-seq "abc")
(reverse #(1 2 3))                             ; #(3 2 1)
(concatenate 'list '(1 2) #(3 4))              ; (1 2 3 4)
(map 'vector #'1+ '(1 2 3))                    ; #(2 3 4)
(map 'list #'cons '(a b) '(1 2))               ; ((A . 1) (B . 2))
(map nil #'print '(1 2))                       ; side effects only
(reduce #'+ '(1 2 3 4))                        ; 10
(reduce #'max '(3 9 2))                        ; 9
(reduce #'+ '(1 2 3) :initial-value 100)       ; 106
(reduce #'list '(1 2 3) :from-end t)           ; (1 (2 3))
(find 3 '(1 2 3 4))                            ; 3
(find "b" '("a" "b") :test #'string=)          ; "b"
(find-if #'evenp '(1 3 4 5))                   ; 4
(find 30 '((ana 30) (bo 25)) :key #'second)    ; (ANA 30)
(position #\a "banana")                        ; 1
(position #\a "banana" :from-end t)            ; 5
(count #\a "banana")                           ; 3
(count-if #'evenp '(1 2 3 4))                  ; 2
(remove 1 '(1 2 1 3))                          ; (2 3)
(remove-if #'evenp '(1 2 3 4)
…