How does one reduce a list of boolean values in Common Lisp?
Posted
by
postfuturist
on Stack Overflow
See other posts from Stack Overflow
or by postfuturist
Published on 2010-12-26T20:13:36Z
Indexed on
2010/12/28
21:54 UTC
Read the original article
Hit count: 234
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?
© Stack Overflow or respective owner