Created
March 27, 2012 23:28
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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