File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -131,11 +131,34 @@ end
131
131
isgensym (s:: Symbol ) = contains (string (s), " #" )
132
132
isgensym (s) = false
133
133
134
+ """
135
+ gensyms_to_ids(expr)
136
+
137
+ Replaces gensyms with unique ids (deterministically)
138
+ """
139
+ function gensyms_to_ids (ex)
140
+ counter = 0
141
+ base_id = " sym_id_"
142
+ syms = Dict {Symbol, Symbol} ()
143
+ prewalk (ex) do x
144
+ if isgensym (x)
145
+ repl_sym = Symbol (" $base_id$counter " )
146
+ # tried the following, but it did not work:
147
+ # repl_sym = Symbol(replace(string(x), "#", ""))
148
+ counter+= 1
149
+ Base. @get! (syms, x, repl_sym)
150
+ else
151
+ x
152
+ end
153
+
154
+ end
155
+ end
156
+
134
157
"""
135
158
alias_gensyms(expr)
136
159
137
- Replaces gensyms with animal names. This makes gensym'd code far easier to
138
- follow.
160
+ Replaces gensyms with animal names
161
+ This makes gensym'd code far easier to follow.
139
162
"""
140
163
function alias_gensyms (ex)
141
164
left = copy (animals)
You can’t perform that action at this time.
0 commit comments