Skip to content

Commit d80a17e

Browse files
committed
better variable name calc->operators
1 parent 128fc1e commit d80a17e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

data_structures/stacks/prefix_evaluation.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
https://en.wikipedia.org/wiki/Polish_notation
44
"""
55

6-
calc = {
6+
operators = {
77
"+": lambda x, y: x + y,
88
"-": lambda x, y: x - y,
99
"*": lambda x, y: x * y,
@@ -42,11 +42,11 @@ def evaluate(expression):
4242
stack.append(int(c))
4343

4444
else:
45-
# pop values from stack can calculate the result
45+
# pop values from stack can operatorsulate the result
4646
# push the result onto the stack again
4747
o1 = stack.pop()
4848
o2 = stack.pop()
49-
stack.append(calc[c](o1, o2))
49+
stack.append(operators[c](o1, o2))
5050

5151
return stack.pop()
5252

@@ -65,10 +65,10 @@ def evaluate_recursive(expression: list):
6565
"""
6666

6767
op = expression.pop(0)
68-
if op not in calc:
68+
if op not in operators:
6969
return float(op)
7070

71-
operation = calc[op]
71+
operation = operators[op]
7272

7373
a = evaluate_recursive(expression)
7474
b = evaluate_recursive(expression)

0 commit comments

Comments
 (0)