Structured math expression representation & parsing.
Project description
human_math
A mathematical expression parser
Example usage
>>> import human_math as hm # import module
>>> tree = hm.parse("2 - (-sin(3pi/2)) - 3.0") # parse string (user input, etc.)
>>> tree
((2 - (-1 * sin(3 * (pi / 2)))) - 3) # console representation uses parentheses everywhere to be strictly non-ambigious
>>> tree.evaluate() # evaluate the expression tree
-2 # nb: sin(3pi/2) = -1 so 2 - (-1) - 3 = -2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
human_math-0.1.tar.gz
(12.2 kB
view hashes)
Built Distribution
human_math-0.1-py3-none-any.whl
(13.1 kB
view hashes)