Skip to content

Instantly share code, notes, and snippets.

crocket

Block or report user

Report or block crocket

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@crocket
crocket / if-let-all.clj
Created Jun 5, 2015
if-let-all clojure macro
View if-let-all.clj
(defmacro if-let-all
"if-let-all evaluates every local binding sequentially and evaluates true-case only if every local binding is a truthy value.
true-case has access to all local bindings, but false-case doesn't have access to local bindings."
[bindings true-case false-case]
(let [pairs (partition 2 bindings)
names (mapv first pairs)
exprs (map second pairs)
exprs-in-if-let (fn self [[name1 & more-names] [expr1 & more-exprs]]
`(if-let [~name1 ~expr1]
~(if more-names
You can’t perform that action at this time.