Scheme uses the syntax
for Boolean true and false value. For example the
“less-than” function is named
Its result is true if the first argument is less than the second (or if
there are more than two arguments: that they are in increasing order):
(< 3 4) ⇒ #t (< -3 -4) ⇒ #f (< 2 3 5 7 11)) ⇒ #t
if special form takes two or three sub-expressions:
It evaluates the first expression.
If that is true it evaluates the second expression;
otherwise it evaluates the third expression, if provided:
(if (< 3 4) (+ 5 5) (+ 5 6)) ⇒ 10
if a special form rather than a function,
because for a function all the arguments are evaluated before the
function is called, but in a special form that is not neceassarily the case.
In addition to
#t any value except
counts as “true” when evaluating the first expression of an
(if 0 (+ 5 5) (+ 5 6)) ⇒ 11
You can use
and to create complex boolean expressions.
are special forms that only evaluate as many of the sub-expressions as needed.
(if (not (and (>= i 0) (<= i 9))) (display "error"))
You can use
cond form as an alternative to
(cond ((< 3 3) 'greater) ((> 3 3) 'less) (else ’equal)) ⇒ equal
The null values (written as
#!null in Kawa or
null in Java)
is also considered to false.