chickadee » srfi-1 » count

count pred clist_1 clist_2procedure

PRED is a procedure taking as many arguments as there are lists and returning a single value. It is applied element-wise to the elements of the LISTs, and a count is tallied of the number of elements that produce a true value. This count is returned. count is "iterative" in that it is guaranteed to apply PRED to the LIST elements in a left-to-right order. The counting stops when the shortest list expires.

(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