Created
April 28, 2014 16:04
-
-
Save maxcountryman/11376431 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 loop-vars | |
"Like loop, but will automatically populate recur points where the special | |
var recur-> is found. | |
Mostly useful in mutable contexts, where some external factor causes the | |
recur bindings to change. | |
" | |
[bindings & body] | |
{:pre [(and (vector? bindings) | |
(even? (count bindings)))]} | |
`(loop ~bindings | |
~@(walk/postwalk | |
(fn find-recur-> [x] | |
(if (= x 'recur->) | |
`(recur ~@(map second (partition 2 bindings))) | |
x)) | |
body))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment