Created
March 30, 2010 01:14
-
-
Save chrisschreiner/348639 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(use 'clojure.walk) | |
(defmacro with-iota [& body] | |
"Provides the local 'iota' which starts at 0 and automatically self-increments" | |
(let [iota (gensym "whatever-")] | |
`(let [~iota ~(atom -1)] | |
~@(map #(postwalk-replace {'iota `(swap! ~iota inc)} %) body)))) | |
(with-iota | |
(let [a iota | |
b iota | |
c iota] | |
(apply println [a b c]))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment