and vs. and (newbie question)
- From: Karstens Rage <karstens@xxxxxxxx>
- Date: Sun, 21 Aug 2005 15:44:03 -0700
I had a hard time searching for this on the newsgroups since and is not
considered a keyword. I am trying to learn LISP and I came across a very
confusing issue (for me anyway).
There is an example in "Common Lisp" by David Touretzky that I just dont
get.
In Chapter 4 Advanced Topic he talks about Boolean functions. The
example is:
(defun logical-and (x y) (and x y t))
and then shows:
(logical-and 'tweet 'woof) -> t
and
(and 'tweet 'woof) -> woof
I completely understand that that last to evaluate as non-nil is
returned and in the first case the "t" is evaluated last and in the
second 'woof is evaluated last.
But then he goes on to show:
(and (numberp 'fred) (oddp 'fred)) -> nil
but
(logical-and (numberp 'fred) (oddp 'fred)) -> generates an error from
oddp. And sure enough it does.
Why is the and in logical-and any different than the and not in logical
and? I.e. why does (oddp 'fred) evaluate when (numberp 'fred) has
already evaluated to nil?
k
.
- Follow-Ups:
- Re: and vs. and (newbie question)
- From: nepheles
- Re: and vs. and (newbie question)
- From: Peter Seibel
- Re: and vs. and (newbie question)
- Prev by Date: Re: Lisp's QUOTE and Mathematica's "Hold"
- Next by Date: Re: Lisp's QUOTE and Mathematica's "Hold"
- Previous by thread: Re: Interested in learning LISP
- Next by thread: Re: and vs. and (newbie question)
- Index(es):
Relevant Pages
|