Reverse Polish Notation or postfix notation, application to convert math expression to RPN with debugstep-by-step and solver using Golang
Turn a math expression like
( 2 + 3 ) * 2 - 2 * 2 * 3
Into Reverse Polish Notation or postfix notation
2 3 + 2 * 2 2 * 3 * -
And solve it
-2
Debug, step-by-step how this app is converting
go run rpngo.go MATH_EXPRESSION [-d]
-d is for debug
go run rpngo.go "10+9+9*(9+6)"
It will return 154
go run rpngo.go "10+9+9*(9+6)" -d
It will return all debug info and entire stacking process
In the rpngo_test.go file there are some test cases, but it is still in progress
Example of test function TestSomeExpression() on file rpngo_test.go
{expression: "7+8", rpn_expression: "7 8 +", result: 15, isResultCorrect: true},
expression is the math expression
rpn_expression is the rpn (expected)
result is the result of this expression
isResultCorrect is a boolean to test a wrong result (use true when rpn_expression and result are OK)
Then, just run
go test -v