Last active
December 1, 2015 08:39
-
-
Save philjackson/64f51d803f585330bb20 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 condev | |
"Takes clauses in the same style as `cond` but, if the left side is | |
truthy, will execute the right side of the expressions as a function | |
which gets the result of evaluation of the left side." | |
[& clauses] | |
(assert (even? (count clauses))) | |
(let [pstep (fn [[test step]] `(when-let [r# ~test] (~step r#)))] | |
`(list ~@(map pstep (partition 2 clauses))))) |
Author
philjackson
commented
Nov 30, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment