(match val ..clauses) val: any form clauses: zero or more arrs
M
Attempt to match a value against several patterns.
Each clause must be a pattern, followed by zero or more
forms. The match
macro evaluates val
, then attempts to match it against each pattern
in turn, evaluating and returning the body of the first clause which matches.
If none of the patterns match, the match
form returns #n
.
(match arg
(i : int?
"the integer {i}")
((a : int?, b : int?)
"a pair of integers, ({a} {b})")
(_ : obj?
"an object")
(arg
(bail "unexpected argument {arg}")))