Email or username:

Password:

Forgot your password?
Top-level
Niki Tonsky

Better cond:

(defmacro cond+ [& clauses]
(when-some [[test expr & rest] clauses]
(condp = test
:do `(do ~expr (cond+ ~@rest))
:let `(let ~expr (cond+ ~@rest))
:some `(or ~expr (cond+ ~@rest))
`(if ~test ~expr (cond+ ~@rest)))))

Use it like this:

(cond+
(= a 1) true
:let [b (- a)]
(= b 1) false
:do (println (+ a b))
:else nil))

2 comments
Steven Deobald

@nikitonsky maybe somebody should do the classic clj kitchensink lib thing but only with fns that meet this constraint

Go Up