if is a two-way Boolean conditional.
Syntax
(if ⟨test-expr⟩ ⟨then-expr⟩ ⟨else-expr⟩)
Semantics
⟨test-expr⟩must be a CoaltonBoolean.ifmust always have a consequent and alternative.- For multi-armed conditionals, use
cond. - For structural branching on algebraic data, use
match. - Stylistically,
ifshould only be used for pure computations; side-effectful computations should always usecond. - It is not recommended to use
prognwithif.
Example
(if (zero? n) 0 1)