SRFI-1: The List Library

Sorting isn't in R7RS-small: use SRFI-132 ((list-sort < lst), vector-sort), R6RS (list-sort < lst), or Guile's (sort lst <).

(import (srfi 1))      ; R7RS-style import; Guile: (use-modules (srfi srfi-1)); Chez: via a library

(iota 5)                              ; (0 1 2 3 4)
(iota 5 1)                            ; (1 2 3 4 5)
(first '(a b c)) (second '(a b c)) (last '(a b c))   ; a b c
(take '(a b c d) 2) (drop '(a b c d) 2)              ; (a b) (c d)
(take-while even? '(2 4 5 6)) (drop-while even? '(2 4 5 6))   ; (2 4) (5 6)
(split-at '(a b c d) 1)                              ; (a) (b c d) (two values)
(filter odd? '(1 2 3 4 5))                           ; (1 3 5)
(remove odd? '(1 2 3 4 5))                           ; (2 4)
(partition odd? '(1 2 3 4))                          ; (1 3) (2 4) (two values)
(fold + 0 '(1 2 3))                                  ; 6
(fold cons '() '(1 2 3))                             ; (3 2 1)
(fold-right cons '() '(1 2 3))                       ; (1 2 3)
(reduce max 0 '(3 9 2))                              ; 9
(append-map (lambda (x) (list x x)) '(1 2))          ; (1 1 2 2)
(filter-map (lambda (x) (and (even? x) (* x x))) '(1 2 3 4))   ; (4 16)
(find even? '(1 3 4 5))                              ; 4
(find-tail even? '(1 3 4 5))                         ; (4 5)
(any even? '
…