diff --git a/src/main/py/read_math_function.py b/src/main/py/read_math_function.py index 402e389..f3c741b 100644 --- a/src/main/py/read_math_function.py +++ b/src/main/py/read_math_function.py @@ -52,6 +52,11 @@ def simplify_easy_math_function(type, function): return False if is_string(function) is False or is_allowed_string("c", function) is True: return simplify_constant("c", function) + extracted_function = extract_constant(function) + simplified_constant = simplify_constant("c", extracted_function[0]) + extracted_function[0] = simplified_constant + return extracted_function + def extract_constant(function): diff --git a/src/test/py/test_read_math_function.py b/src/test/py/test_read_math_function.py index 90a890f..7597ff7 100644 --- a/src/test/py/test_read_math_function.py +++ b/src/test/py/test_read_math_function.py @@ -46,6 +46,8 @@ class read_function(unittest.TestCase): self.assertEqual(extract_constant("42x"), ["0", "42x"]) def test_extraction_linear_function_constant_with_math_operators(self): self.assertEqual(extract_constant("42x+42^(2)+1-3*4/3"), ["42^(2)+1-3*4/3", "42x"]) + def test_easy_function_linear_constant_gets_simplified(self): + self.assertEqual(simplify_easy_math_function("v", "42x+42^(2)+1-3*4/3"), [1761, "42x"]) if __name__ == '__main__': unittest.main()