Closed skx closed 4 years ago
The calculator currently allows either:
The latter case should allow variables. Something like:
rent = 710 rent * 6 / 12
This does mean dropping the current go-based scanner/lexer/evaluator. But writing a calculator is a trivial thing, even with precedence and variables.
I've hacked up a simple calculator which supports variables, albeit with a let x = prefix.
let x =
It handles +, -, *, /, with floating point, and appropriate precedence.
+
-
*
/
TODO:
The calculator currently allows either:
The latter case should allow variables. Something like:
This does mean dropping the current go-based scanner/lexer/evaluator. But writing a calculator is a trivial thing, even with precedence and variables.