Created
November 5, 2016 23:46
-
-
Save shirok/7d48364cb13262045c3d00ac8db72f67 to your computer and use it in GitHub Desktop.
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 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