Skip to content

Instantly share code, notes, and snippets.

@jboverfelt
Created January 10, 2014 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jboverfelt/8364848 to your computer and use it in GitHub Desktop.
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.
(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