Conditionals

(if {test} {consequent} {alternate} ) syntax
(if {test} {consequent} ) syntax

Syntax: Test, consequent, and alternate are expressions.

Semantics: An if expression is evaluated as follows: first, test is evaluated. If it yields a true value (see section 6.3), then consequent is evaluated and its values are returned. Otherwise alternate is evaluated and its values are returned. If test yields a false value and no alternate is specified, then the result of the expression is unspecified.

(if (> 3 2) 'yes 'no) ==> yes (if (> 2 3) 'yes 'no) ==> no (if (> 3 2) (- 3 2) (+ 3 2)) ==> 1

husk-scheme online documentation rev 3.2 (2021.03.04)