Arc Cross Reference

firstn-that

[procedure] firstn-that n f xs

Returns a list of up to n elements, each of which satisfies f in xs.

(def firstn-that (n f xs)
  (if (or (<= n 0) (no xs))
       nil
      (f (car xs))
       (cons (car xs) (firstn-that (- n 1) f (cdr xs)))
       (firstn-that n f (cdr xs))))

See also: firstn.