It is a conditional syntactic form, or it might be implemented as a macro that expands to some core syntax form, which is treated as a special case by the compiler/interpreter.
The list there in Racket's docs includes if
as a special form but doesn't include and
, so the latter most probably is implemented in terms of the former. But R5RS does list and
as a syntactic keyword. So, best we can say, it's either a special syntax, or a macro.
It is easy to re-write any and
form (and a b c ...)
as an if
form, (if a (if b (if c #t #f) #f) #f)
.
lambda
is fine by me, but you can also use every
from SRFI-1 (or Racket's andmap
):
(every identity '(#t #f))
should return #f
.
edit: except, as Joshua Taylor points out, calling your lambda
through a function like foldl
does not short-circuit. Which defeats the purpose to calling the and
in the first place.
Another thing is, in Racket's foldl
the last argument to lambda
is the one that receives the previous result in the chain of applications; so the implementation should really be
(foldl (lambda (a b) (and b a)) #t '(#t #f))