Skip to content

Instantly share code, notes, and snippets.

@reinhrst
Created March 27, 2012 23:28
Show Gist options
  • Save reinhrst/2221458 to your computer and use it in GitHub Desktop.
Save reinhrst/2221458 to your computer and use it in GitHub Desktop.
lazy-or macro. Only evaluates contents as long as they return falsy, returns the first truthy value
(defmacro lazy-or [& block]
(case (count block)
0 nil
1 (first block)
`(if-let [result# ~(first block)]
result#
(lazy-or ~@(rest block)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment