cond is Coalton’s multi-branch conditional.
Syntax
(cond
(⟨test-expr⟩ ⟨result-expr⟩...)
...
(True ⟨fallback-expr⟩...))
Semantics
- Branches are considered in order.
- The first
Truetest wins. Trueis commonly used as the final catch-all branch.- Each branch result has an implicit
progn, and therefore multiple expressions and short-lets are permitted. condis preferred overifif the branches have side-effects.
Example
(cond
((< n 0) -1)
((== n 0) 0)
(True 1))