Re: (apply and (list #t #f #t))
Roland Orre (orre@nada.kth.se)
Thu, 30 Oct 1997 17:41:02 +0100 (MET)
Sascha Ziemann <szi@aibon.ping.de> wrote:
> is it intended that this is not possible?
> (apply and (list #t #f #t))
In scheme "and" is a special form, which not necessarily evaluates its
arguments. In other LISPs you usually have different ways of defining
procedures as e.g. "(lambda .." and "(nlambda ..", where the latter one
does not evaluate its argument. In scheme you have procedures "lambda",
which always evaluates and special forms (macros and syntax).
In scheme "and" is not a procedure and can not be applied. You have to
write and own function for that, like:
(define (land . rest)
(if (pair? rest)
(if (pair? (cdr rest))
(and (car rest) (apply land (cdr rest)))
(car rest))
#f))
Best regards
Roland