How does one reduce a list of boolean values in Common Lisp?
- by postfuturist
Given a list of values, I want to reduce the list to T if all the elements are not NIL, NIL if not. This gives me an error:
(apply #'and (get-some-list))
As does this:
(reduce #'and (get-some-list))
This is the best I've come up with:
[11]> (defun my-and (x y) (and x y))
MY-AND
[12]> (reduce #'my-and '(T T T T T))
T
[13]> (reduce #'my-and '(T T T T NIL))
NIL
Why is "#'and" invalid? Is there a more idiomatic way to do this in Common Lisp?