ee – evaluate expression

· 168 words · 1 minute read

An oddity in my mind is the lack of a simple calculator on the typical Linux command line (e.g. one that isn’t python). Coincidentally, one of my class projects at Texas Tech was just such a program. The class version had some extra things, though. For example in addition to being a natural stack-based Reverse Polish Notation calculator, it had a binary tree for storing an abstract syntax tree, and converted the expression to infix.

I use that program surprisingly often, but it wasn’t until today I realized it only supported integers. Time for a rewrite.

The new implementation uses only a single stack structure, and uses double-precision floating point variables instead of integers. It uses global variables for input checking, and is much more open to operators with non-binary arity than my previous implementation. It also supports exponentiation and factorials, unlike my previous implementation.

I’ll be adding more documentation to the new implementation in the next few days, but it is available now from the projects page.