Next: Symbols, Previous: Miscellaneous Datatypes, Up: Miscellaneous Datatypes [Contents][Index]
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 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
This predicate is true iff the boolean args are either all true or all false.
Implementation note: The standard requires this procedure’s arguments
to satisfy boolean?
, but MIT/GNU Scheme allows any object to be
an argument.
This procedure returns #t
if none of its arguments are #f
.
Otherwise it returns #f
.
This procedure returns #f
if all of its arguments are #f
.
Otherwise it returns #t
.
Next: Symbols, Previous: Miscellaneous Datatypes, Up: Miscellaneous Datatypes [Contents][Index]