Node:Booleans, Next:Numbers, Up:Simple Data Types
The two boolean values are
#t for true and
#f for false.
Boolean values are returned by predicate procedures, such as the general
(see Equality) and numerical and string comparison operators like
string=? (see String Comparison) and
(<= 3 8) => #t (<= 3 -3) => #f (equal? "house" "houses") => #f (eq? #f #f) => #t
In test condition contexts like
cond (see if cond case), where a group of subexpressions will be evaluated only if a
condition expression evaluates to "true", "true" means any
value at all except
(if #t "yes" "no") => "yes" (if 0 "yes" "no") => "yes" (if #f "yes" "no") => "no"
A result of this asymmetry is that typical Scheme source code more often
#f explicitly than
#f is necessary to
cond false value, whereas
not necessary to represent an
cond true value.
It is important to note that
#f is not equivalent to any
other Scheme value. In particular,
#f is not the same as the
number 0 (like in C and C++), and not the same as the "empty list"
(like in some Lisp dialects).
not procedure returns the boolean inverse of its argument:
|not x||Scheme Procedure|
|scm_not (x)||C Function|
boolean? procedure is a predicate that returns
its argument is one of the boolean values, otherwise
|boolean? obj||Scheme Procedure|
|scm_boolean_p (obj)||C Function|