The standard boolean objects for true and false are written as #t
and #f
.
Alternatively, they may be written #true
and #false
,
respectively.
test-expression
::=
expression
What really matters,
though, are the objects that the Scheme conditional expressions (if
,
cond
, and
, or
, when
, unless
, do
)
treat as true or
false. The phrase “a true value” (or sometimes just “true”)
means any object treated as true by the conditional expressions, and the phrase “a false value” (or “false”) means any
object treated as false by the conditional expressions.
In this document, test-expression
is an expression that is evaluated,
but we only care about whether the result is a true or a false value.
Of all the standard Scheme values, only #f
counts as false in
conditional expressions. All other Scheme values, including #t
,
count as true. A test-expression
is an expression evaluated
in this manner for whether it is true or false.
In addition the null value #!null
(in Java written as null
)
is also considered false. Also, if you for some strange reason create a
fresh java.lang.Boolean
object whose booleanValue()
returns false
, that is also considered false.
Note: Unlike some other dialects of Lisp, Scheme distinguishes
#f
and the empty list from each other and from the symbol
nil
.
Boolean constants evaluate to themselves, so they do not need to be quoted in programs.
#t ⇒ #t #true ⇒ #t #f ⇒ #f #false ⇒ #f '#f ⇒ #f
The type of boolean values. As a type conversion, a true value is converted to
#t
, while a false value is converted to#f
. Represented as a primitive Javaboolean
orkawa.lang.Boolean
when converted to an object.
The
boolean?
predicate returns#t
ifobj
is either#t
or#f
, and returns#f
otherwise.(boolean? #f) ⇒ #t (boolean? 0) ⇒ #f (boolean? '()) ⇒ #f
Procedure: boolean=?
boolean1
boolean2
boolean3
...
Returns
#t
if all the arguments are booleans and all are#t
or all are#f
.