This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (apply and (list #t #f #t))


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