[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.2.4 List miscellaneous routines

Function: length+ x
[SRFI-1] If x is a proper list, returns its length. Otherwise, returns #f.

Function: concatenate list-of-lists
Function: concatenate! list-of-lists!
[SRFI-1] Equivalent to (apply append list-of-lists) and (apply append! list-of-lists), respectively.

Function: append-reverse rev-head tail
Function: append-reverse! rev-head tail
[SRFI-1] append-reverse returns (append (reverse rev-head) tail). append-reverse! is the linear-update variant.

Function: zip clist1 clist2 ...
[SRFI-1] Equivalent to (map list clist1 clist2 ...). If zip is passed n lists, it returns a list as long as the shortest of these lists, each element of which is an n-element list comprised of the corresponding elements from the parameter lists.
 
(zip '(one two three) 
     '(1 2 3)
     '(odd even odd even odd even odd even))
     => ((one 1 odd) (two 2 even) (three 3 odd))

(zip '(1 2 3)) => ((1) (2) (3))
At least one of the argument lists must be finite:
 
(zip '(3 1 4 1) (circular-list #f #t)) 
     => ((3 #f) (1 #t) (4 #f) (1 #t))

Function: unzip1 list
Function: unzip2 list
Function: unzip3 list
Function: unzip4 list
Function: unzip5 list
[SRFI-1] unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so on.
 
(unzip2 '((1 one) (2 two) (3 three))) =>
   (1 2 3) and
   (one two three)

Function: count pred clist1 clist2 ...
[SRFI-1] A procedure pred is applied to the n-th element of given lists, from n is zero to the length of the the shortest finite list in the given lists, and the count of times pred returned true is returned.
 
(count even? '(3 1 4 1 5 9 2 5 6)) => 3
(count < '(1 2 4 8) '(2 4 6 8 10 12 14 16)) => 3
At least one of the argument lists must be finite:
 
(count < '(3 1 4 1) (circular-list 1 10)) => 2

Function: count$ pred
Partial application version of count
 
((count$ pred) arg ...) === (count pred arg ...)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html