(cond-eq? arg ..clauses) arg: any form clauses: zero or more arrs
M
Successively tests a value for equality using eq?
.
cond-eq?
evaluates arg
and repeatedly tests it for equality against the first
form in each clause, using eq?
. The first matching clause is evaluated and
returned.
As for cond
, the final clause may start with the symbol else
.
Any clause may start with the symbol any-of
, followed by an array of forms. In that
case, arg
is compared against each form in turn.
(cond-eq? x
((+ 2 3)
(prn "x is 5"))
(any-of (3 4)
(prn "x is 3 or 4"))
(else
(bail)))
; ...is equivalent to...
(let arg x)
(cond
((eq? x (+ 2 3))
(prn "x is 5"))
((eq-any? x 3 4)
(prn "x is 3 or 4"))
(else
(bail)))