Skip to content
Snippets Groups Projects
Commit 496cbad4 authored by Alexandre Faure's avatar Alexandre Faure
Browse files

Update operators.py

parent a4fbffa7
Branches
No related tags found
No related merge requests found
Pipeline #46342 failed
"""
Operator module contains the Operator class and a list of standard operators.
"""
class Operator:
"""
Operator class is a binary operator with a symbol, a precedence and an evaluation function.
"""
def __init__(self, symbol, precedence, evaluate_function):
self.symbol = symbol
self.precedence = precedence
......@@ -17,4 +20,5 @@ class Operator:
return self.evaluate_function(left, right)
STANDARD_OPERATORS = { '+': Operator('+', 1, lambda a, b: a + b),'-': Operator('-', 1, lambda a, b: a - b),'*': Operator('×', 2, lambda a, b: a * b),'/': Operator('/', 2, lambda a, b: a / b)}
STANDARD_OPERATORS = {'+': Operator('+', 1, lambda a, b: a + b), '-': Operator('-', 1, lambda a,
b: a - b), '*': Operator('×', 2, lambda a, b: a * b), '/': Operator('/', 2, lambda a, b: a / b)}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment