data_structures.stacks.infix_to_postfix_conversion¶
https://en.wikipedia.org/wiki/Infix_notation https://en.wikipedia.org/wiki/Reverse_Polish_notation https://en.wikipedia.org/wiki/Shunting-yard_algorithm
Attributes¶
Functions¶
|
Return the associativity of the operator char. |
|
|
|
Return integer value representing an operator's precedence, or |
Module Contents¶
- data_structures.stacks.infix_to_postfix_conversion.associativity(char: str) Literal['LR', 'RL'] ¶
Return the associativity of the operator char. https://en.wikipedia.org/wiki/Operator_associativity
- data_structures.stacks.infix_to_postfix_conversion.infix_to_postfix(expression_str: str) str ¶
>>> infix_to_postfix("(1*(2+3)+4))") Traceback (most recent call last): ... ValueError: Mismatched parentheses >>> infix_to_postfix("") '' >>> infix_to_postfix("3+2") '3 2 +' >>> infix_to_postfix("(3+4)*5-6") '3 4 + 5 * 6 -' >>> infix_to_postfix("(1+2)*3/4-5") '1 2 + 3 * 4 / 5 -' >>> infix_to_postfix("a+b*c+(d*e+f)*g") 'a b c * + d e * f + g * +' >>> infix_to_postfix("x^y/(5*z)+2") 'x y ^ 5 z * / 2 +' >>> infix_to_postfix("2^3^2") '2 3 2 ^ ^'
- data_structures.stacks.infix_to_postfix_conversion.precedence(char: str) int ¶
Return integer value representing an operator’s precedence, or order of operation. https://en.wikipedia.org/wiki/Order_of_operations
- data_structures.stacks.infix_to_postfix_conversion.ASSOCIATIVITIES: dict[str, Literal['LR', 'RL']]¶
- data_structures.stacks.infix_to_postfix_conversion.PRECEDENCES: dict[str, int]¶
- data_structures.stacks.infix_to_postfix_conversion.expression = 'a+b*(c^d-e)^(f+g*h)-i'¶