Eliminated repetitive replacement calls.

parent 40286033
...@@ -158,11 +158,11 @@ def generate_line(root): ...@@ -158,11 +158,11 @@ def generate_line(root):
# Function call # Function call
result = op + '(' + ', '.join(map(traverse, node)) + ')' result = op + '(' + ', '.join(map(traverse, node)) + ')'
return result
# An addition with negation can be written as a subtraction, e.g.: # An addition with negation can be written as a subtraction, e.g.:
# 1 + -2 -> 1 - 2 # 1 + -2 -> 1 - 2
return result.replace('+ -', '- ') return traverse(root).replace('+ -', '- ')
return traverse(root)
def is_negation(node): def is_negation(node):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment