Re: apply with logicals

From: Jason Riedy <>
Date: Wed, 03 Apr 1996 10:13:51 -0500

Oh well. And Andrew Dorrell writes:
 - Perhaps someone will know... Is there some good reason why this fails:
 - STk> (apply and '(#t #t #f))
 - *** Error:
 - apply: bad procedure: #[subr and]

This isn't something particular to any scheme implementation; none should
allow applying and. Apply only works with functions.

To support short-circuit evaluation, and is a special form. Any procedure
will evaluate both its arguments before binding them to the appropriate
parameters. If and evaluated its arguments, code like
  (and (< n (vector-length v))
       (not (= 0 (vector-ref v n))) )
might not work as expected. (This is another reason why '() is different
than #f... What should the above return if the n'th entry of the vector
is the empty list?)

The solution is, erm, left as an exercise to the reader. ;) (The scheme
I'm tearing apart currently/temporarily seems to have misplaced unquote...)

Received on Wed Apr 03 1996 - 17:16:21 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST