From b4521ea28f4377774832008ecdda87ca171155c0 Mon Sep 17 00:00:00 2001 From: Arijit De Date: Fri, 4 Aug 2023 21:27:20 +0530 Subject: [PATCH] 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. --- data_structures/stacks/postfix_evaluation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data_structures/stacks/postfix_evaluation.py b/data_structures/stacks/postfix_evaluation.py index 808162faf..36062abb1 100644 --- a/data_structures/stacks/postfix_evaluation.py +++ b/data_structures/stacks/postfix_evaluation.py @@ -88,6 +88,8 @@ def evaluate(post_fix: list[str], verbose: bool = False) -> int | float | str | 6.6 >>> evaluate(["2", "-", "3", "+"]) 1 + >>> evaluate(["-4", "5", "*", "6", "-"]) + -26 >>> evaluate([]) 0