Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:12
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 rightfold/0c49f29105a8d67b93ee to your computer and use it in GitHub Desktop.
Save rightfold/0c49f29105a8d67b93ee to your computer and use it in GitHub Desktop.
(defmacro cond-let [name & cases]
(when-not (even? (count cases))
(throw (IllegalArgumentException. "cond-let requires an odd number of forms")))
(if (empty? cases)
nil
`(if-let [~name ~(first cases)]
~(second cases)
(cond-let ~name ~@(drop 2 cases)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment