Re: (apply #'and '(t t nil)) not work
- From: "Alex Mizrahi" <udodenko@xxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 31 Mar 2008 16:49:58 +0300
f> Apparently and is not a normal function like +, -, ...
f> I can write (and t t nil), but if the parameters are packaged into a
f> list, how can I do?
indeed, AND is not a function, it's a special operator, pretty close to IF
or WHEN -- it stops evaluating as soon as it get first NIL (this is called
short circuiting sometimes).
there is a function called EVERY, it does exactly what you need:
CL-USER> (every #'identity '(t t nil))
NIL
CL-USER> (every #'identity '(t t t))
T
of course you can define your own function -- to get rid of #'indetity
parameter, or allowing it to agruments directly. i.e.
(defun my-and (&rest args) (every #'identity args))
CL-USER> (my-and t t nil)
NIL
CL-USER> (apply #'my-and '(t t nil))
NIL
this looks just like AND, but it does not short-circuit evaluation.
.
- Follow-Ups:
- Re: (apply #'and '(t t nil)) not work
- From: fishmacs
- Re: (apply #'and '(t t nil)) not work
- References:
- (apply #'and '(t t nil)) not work
- From: fishmacs
- (apply #'and '(t t nil)) not work
- Prev by Date: Re: (apply #'and '(t t nil)) not work
- Next by Date: Re: (apply #'and '(t t nil)) not work
- Previous by thread: Re: (apply #'and '(t t nil)) not work
- Next by thread: Re: (apply #'and '(t t nil)) not work
- Index(es):
Relevant Pages
|