-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Added calculator/math_parser.py full code #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, man
I will accept this one after the fixes. but in the future, I am thinking we should move the whole design related stuff to another repo and focus only algorithmic stuff here. What do you think?
calculator/math_parser.py
Outdated
| """ | ||
| return token in __operators__ | ||
|
|
||
| def higherPriority(op1, op2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snake case
calculator/math_parser.py
Outdated
| '/': 1, | ||
| } | ||
|
|
||
| def isOperator(token): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please convert it to snake case
calculator/math_parser.py
Outdated
| expression String: The expression | ||
| type Type (optional): Number type [int, float] | ||
| """ | ||
| opStack = deque() # operator stack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snake case for the values, too
calculator/math_parser.py
Outdated
| __operators__ = "+-/*" | ||
| __parenthesis__ = "()" | ||
| __priority__ = { | ||
| '+': 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 spaces instead of tab
|
Requested changes applied. |
|
awesome thanks |
|
About the question of move related stuff to other repo, i think this is algorithmic stuff. It uses Dijkstra's Shunting-yard algorithm simplified. |
Working implementation of a "calculator" (math expression parser) using the Shunting-yard algorithm.