Created
January 10, 2014 23:44
-
-
Save jboverfelt/8364848 to your computer and use it in GitHub Desktop.
Implementation of the do-until macro described in Fogus' Joy of Clojure using destructuring rather than explicit seq functions like first, second, and nnext. This macro executes all its clauses evaluating to true until it hits something falsey.
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 do-until [& clauses] | |
(when-let [[first second & rest] clauses] | |
(list 'when first | |
(if second | |
second | |
(throw (IllegalArgumentException. "do-until requires an even number of forms"))) | |
(cons 'do-until rest)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment