(def span (tst lst)
((afn (a lst)
(if (and lst (tst (car lst)))
(self (cons (car lst) a) (cdr lst))
(list (rev a) lst)))
nil lst))
span splits a list into two lists: the first list is the longest prefix of the input list for which each element passes the test, and the second list is the rest of the list.
arc> (span even '(4 6 8 1 3 4 7 8)) ((4 6 8) (1 3 4 7 8))
Using the hackinator:
$ hack \
ycombinator.com/arc/arc3.1.tar \
awwx.ws/span0.arcThis code is in the public domain.