Sequence Predicates

Four other handy functions are **EVERY**, **SOME**, **NOTANY**, and **NOTEVERY**, which iterate over sequences testing a boolean predicate. The first argument to all these functions is the predicate, and the remaining arguments are sequences. The predicate should take as many arguments as the number of sequences passed. The elements of the sequences are passed to the predicate—one element from each sequence—until one of the sequences runs out of elements or the overall termination test is met: **EVERY** terminates, returning false, as soon as the predicate fails. If the predicate is always satisfied, it returns true. **SOME** returns the first non-**NIL** value returned by the predicate or returns false if the predicate is never satisfied. **NOTANY** returns false as soon as the predicate is satisfied or true if it never is. And **NOTEVERY** returns true as soon as the predicate fails or false if the predicate is always satisfied. Here are some examples of testing just one sequence:

  1. (every #'evenp #(1 2 3 4 5)) ==> NIL
  2. (some #'evenp #(1 2 3 4 5)) ==> T
  3. (notany #'evenp #(1 2 3 4 5)) ==> NIL
  4. (notevery #'evenp #(1 2 3 4 5)) ==> T

These calls compare elements of two sequences pairwise:

  1. (every #'> #(1 2 3 4) #(5 4 3 2)) ==> NIL
  2. (some #'> #(1 2 3 4) #(5 4 3 2)) ==> T
  3. (notany #'> #(1 2 3 4) #(5 4 3 2)) ==> NIL
  4. (notevery #'> #(1 2 3 4) #(5 4 3 2)) ==> T