cond
performs conditional branching
Usage:
(cond [pred then]*)
For each pred-then clause, the predicate will be evaluated, and if it is truthy (not false), the then form is evaluated and returned, otherwise the next clause is processed.
An Example
(define x 99)
(cond
[(< x 50) "was less than 50" ]
[(> x 100) "was greater than 100"]
[:else "was in between" ])
In this case, “was in between” will be returned. The reason that this works is that the :else
keyword, like all keywords, evaluates to truthy.