Skip to content

Instantly share code, notes, and snippets.

@shirok
Created November 5, 2016 23:46
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 shirok/7d48364cb13262045c3d00ac8db72f67 to your computer and use it in GitHub Desktop.
Save shirok/7d48364cb13262045c3d00ac8db72f67 to your computer and use it in GitHub Desktop.
(defmacro when-let* [bindings & body]
(letfn [(rec
([] `(do ~@body))
([var expr & rest] `(if-let [~var ~expr] ~(apply rec rest)))
([var] (throw (Exception. "Odd element in bindings of if-let*"))))]
(apply rec bindings)))
;; Emacs users want this:
;; (put 'when-let* 'clojure-indent-function 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment