Python/data_structures/stacks
Arijit De 0a9438071e
Updated postfix_evaluation.py to support Unary operators (#8787)
* Updated postfix_evaluation.py to support Unary operators and floating point numbers Fixes #8754 and #8724

Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py

Signed-off-by: Arijit De <arijitde2050@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated postfix_evaluation.py to support Unary operators and floating point numbers. Fixes #8754 and formatted code to pass ruff and black test.

Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes #8724 and made sure it passes doctest

Signed-off-by: Arijit De <arijitde2050@gmail.com>

* Fixed return type hinting required by pre commit for evaluate function

Signed-off-by: Arijit De <arijitde2050@gmail.com>

* Changed line 186 to return only top of stack instead of calling the get_number function as it was converting float values to int, resulting in data loss. Fixes #8754 and #8724

Signed-off-by: Arijit De <arijitde2050@gmail.com>

* Made the requested changes

Also changed the code to make the evaluate function first convert all the numbers and then process the valid expression.

* Fixes #8754, #8724 Updated postfix_evaluation.py

postfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes #8724. Added a doctest example with unary operator.

* Fixes #8754, #8724 Updated postfix_evaluation.py

postfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes #8724. Added a doctest example with unary operator.

* Fixes #8754, #8724 Updated the parse_token function of postfix_evaluation.py

ostfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes #8724. Added a doctest example with unary operator and invalid expression.

* Fixes #8754, #8724 Updated postfix_evaluation.py

postfix_evaluation.py now supports Unary operators and floating point numbers.
Also merged evaluate_postfix_notations.py and postfix_evaluation.py into postfix_evaluation.py which fixes #8724. Added a doctest example with unary operator and invalid expression.

* Update postfix_evaluation.py

* Update postfix_evaluation.py

* Update postfix_evaluation.py

* Update postfix_evaluation.py

* Update postfix_evaluation.py

---------

Signed-off-by: Arijit De <arijitde2050@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-08-23 14:36:59 +02:00
..
__init__.py Update infix to postfix (#3817) 2020-11-02 00:35:31 +08:00
balanced_parentheses.py Fix type annotations for stack.py (#5566) 2021-10-26 20:33:08 +02:00
dijkstras_two_stack_algorithm.py Fix some typos (#6113) 2022-05-01 18:44:23 +08:00
infix_to_postfix_conversion.py fixes #8673; Add operator's associativity check for stacks/infix_to_p… (#8674) 2023-08-01 11:23:34 -07:00
infix_to_prefix_conversion.py Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062) 2022-10-13 00:54:20 +02:00
next_greater_element.py Add flake8-builtins to pre-commit and fix errors (#7105) 2022-10-13 19:53:59 +05:30
postfix_evaluation.py Updated postfix_evaluation.py to support Unary operators (#8787) 2023-08-23 14:36:59 +02:00
prefix_evaluation.py pre-commit: Upgrade psf/black for stable style 2023 (#8110) 2023-02-01 18:44:54 +05:30
stack_with_doubly_linked_list.py pre-commit: Upgrade psf/black for stable style 2023 (#8110) 2023-02-01 18:44:54 +05:30
stack_with_singly_linked_list.py refactor: Indent ... for visual purposes (#7744) 2022-10-27 19:42:30 +02:00
stack.py Add more ruff rules (#8767) 2023-05-26 09:34:17 +02:00
stock_span_problem.py pre-commit: Upgrade psf/black for stable style 2023 (#8110) 2023-02-01 18:44:54 +05:30