Skip to content

Commit f168ee9

Browse files
Showcase iterative behavior of simplify_constants
Clarifies variable names and clearly show potentially-nonterminating behavior.
1 parent e5560a7 commit f168ee9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/simplify.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
function simplify_constants(O::Operation, shorten_tree = true)
2-
O_last = nothing
3-
_O = O
4-
while _O != O_last
5-
O_last = _O
6-
_O = _simplify_constants(_O,shorten_tree)
7-
if is_operation(_O)
8-
_O = Operation(_O.op,simplify_constants.(_O.args,shorten_tree))
2+
while true
3+
O′ = _simplify_constants(O, shorten_tree)
4+
if is_operation(O′)
5+
O′ = Operation(O′.op, simplify_constants.(O′.args, shorten_tree))
96
end
7+
O == O′ && return O
8+
O = O′
109
end
11-
_O
1210
end
1311

1412
const AC_OPERATORS = [*, +]

0 commit comments

Comments
 (0)