Last active
November 29, 2021 02:58
-
-
Save minikomi/6bc7df405704ad6773ecc9dc2ad5fc04 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 let-stop [bindings & body] | |
(if (some #{'*stop*} bindings) | |
(let [stopped-bindings | |
(->> bindings | |
(take-while #(not= '*stop* %)) | |
vec) | |
caught-symbols | |
(->> stopped-bindings | |
(partition 2) | |
(map #(vector (keyword (str (first %))) (first %))) | |
(into {}))] | |
`(let ~stopped-bindings | |
~caught-symbols)) | |
`(let* ~(destructure bindings) ~@body))) | |
(let-stop | |
[a 1 | |
b (* a 10) | |
c {:a a :b b} | |
*stop* | |
] | |
(+ a b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment