Created
April 17, 2012 23:12
-
-
Save drlivingston/2409793 to your computer and use it in GitHub Desktop.
deterministic gentemp
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
(def ^:dynamic *gentemp-counters*) | |
(defn new-gentemp-counters [] {}) | |
(defn next-name [name] | |
(let [c (get *gentemp-counters* name 0)] | |
(set! *gentemp-counters* (assoc *gentemp-counters* name (inc c))) | |
(str name "-" c))) | |
(defmacro with-reset-ids [& body] | |
`(binding [*gentemp-counters* (new-gentemp-counters)] | |
~@body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e.g.