such.control-flow

branch-on

macro

(branch-on value-form & body)
(branch-on (str "one" "two")
   vector?   :vector
   string?   :string
   :else     :unknown)

Evaluates the value-form once, then checks that value against each predicate in the cond-like body. The value after the first matching predicate is returned. If there is no match and an :else clause is present, its value is returned, otherwise nil.

let-maybe

macro

(let-maybe bindings & body)

Like let except that if any symbol would be bound to a nil, the entire expression immediately short-circuits and returns nil.

(let-maybe [v []
            f (first v)
            _ (throw (new Exception))]
   (throw (new Exception)))
=> nil