take returns the first i elements of list x.
drop returns all but the first i elements of list x.
(take '(a b c d e) 2) => (a b) (drop '(a b c d e) 2) => (c d e)
x may be any value—a proper, circular, or dotted list:
(take '(1 2 3 . d) 2) => (1 2) (drop '(1 2 3 . d) 2) => (3 . d) (take '(1 2 3 . d) 3) => (1 2 3) (drop '(1 2 3 . d) 3) => d
For a legal i,
drop partition the list in
a manner which can be inverted with
(append (take x i) (drop x i)) = x
drop is exactly equivalent to performing i
operations on x; the returned value shares a common tail with
x. If the argument is a list of non-zero length,
guaranteed to return a freshly-allocated list, even in the case where
the entire list is taken, e.g.
(take lis (length lis)).
list-head is deprecated and should not be used.
list-tail is defined by R7RS.
Start and end must be exact integers satisfying
0 <= start <= end <= (length list)
sublist returns a newly allocated list formed from the elements
of list beginning at index start (inclusive) and ending at
Returns a list consisting of the elements of the first list followed by the elements of the other lists.
(append '(x) '(y)) ⇒ (x y) (append '(a) '(b c d)) ⇒ (a b c d) (append '(a (b)) '((c))) ⇒ (a (b) (c)) (append) ⇒ ()
The resulting list is always newly allocated, except that it shares structure with the last list argument. The last argument may actually be any object; an improper list results if the last argument is not a proper list.
(append '(a b) '(c . d)) ⇒ (a b c . d) (append '() 'a) ⇒ a
Returns a list that is the argument lists concatenated together.
The arguments are changed rather than copied. (Compare this with
append, which copies arguments rather than destroying them.) For
(define x (list 'a 'b 'c)) (define y (list 'd 'e 'f)) (define z (list 'g 'h)) (append! x y z) ⇒ (a b c d e f g h) x ⇒ (a b c d e f g h) y ⇒ (d e f g h) z ⇒ (g h)
last returns the last element of the non-empty, finite list
last-pair returns the last pair in the non-empty,
finite list pair.
(last '(a b c)) => c (last-pair '(a b c)) => (c)