Go to the previous, next section.
The boolean objects are true and false. The boolean constant true is written as `#t', and the boolean constant false is written as `#f'.
The primary use for boolean objects is in the conditional expressions
if
, cond
, and
, and or
; the behavior of these
expressions is determined by whether objects are true or false. These
expressions count only #f
as false. They count everything else,
including #t
, pairs, symbols, numbers, strings, vectors, and
procedures as true (but see section True and False).
Programmers accustomed to other dialects of Lisp should note that Scheme
distinguishes #f
and the empty list from the symbol nil
.
Similarly, #t
is distinguished from the symbol t
. In
fact, the boolean objects (and the empty list) are not symbols at all.
Boolean constants evaluate to themselves, so you don't need to quote them.
#t => #t #f => #f '#f => #f t error--> Unbound variable
These variables are bound to the objects #f
and #t
respectively. The compiler, given the usual-integrations
declaration, replaces references to these variables with their
respective values.
Note that the symbol true
is not equivalent to #t
, and the
symbol false
is not equivalent to #f
.
Returns #t
if object is either #t
or #f
;
otherwise returns #f
.
(boolean? #f) => #t (boolean? 0) => #f
These procedures return #t
if object is false; otherwise
they return #f
. In other words they invert boolean
values. These two procedures have identical semantics; their names are
different to give different connotations to the test.
(not #t) => #f (not 3) => #f (not (list 3)) => #f (not #f) => #t
procedure+: boolean=? obj1 obj2
This predicate is true iff obj1 and obj2 are either both true or both false.
procedure+: boolean/and object ...
This procedure returns #t
if none of its arguments are #f
.
Otherwise it returns #f
.
procedure+: boolean/or object ...
This procedure returns #f
if all of its arguments are #f
.
Otherwise it returns #t
.
Go to the previous, next section.