From d09d8a3d9892d3ca7be5e7733dea3d262492f7d3 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Thu, 20 Sep 2018 18:40:04 +0200 Subject: [PATCH] Put example in API/__ini__ --- mapytex/calculus/API/__init__.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mapytex/calculus/API/__init__.py b/mapytex/calculus/API/__init__.py index ebce9c7..5092337 100644 --- a/mapytex/calculus/API/__init__.py +++ b/mapytex/calculus/API/__init__.py @@ -7,6 +7,31 @@ # Distributed under terms of the MIT license. """ +Generate and compute like a student! + +:example: + +>>> e = Expression.from_str("2+3*4") +>>> e_simplified = e.simplify() +>>> print(e_simplified) +14 +>>> for s in e_simplified.explain(): +... print(s) +2 + 3 * 4 +2 + 12 +14 +>>> e = Expression.from_str("2+3/2") +>>> e_simplified = e.simplify() +>>> print(e_simplified) +7 / 2 +>>> for s in e_simplified.explain(): +... print(s) +2 + 3 / 2 +2 / 1 + 3 / 2 +(2 * 2) / (1 * 2) + 3 / 2 +4 / 2 + 3 / 2 +(4 + 3) / 2 +7 / 2 """