Reverse Polish Notation Calculator
Implemented in different languages
- Learn basics of functional programming:
- Self-education
- Fun
- ...
$ erl
1> c(rpn).
{ok,rpn}
$ erlc rpn.erl
$ erl
1> 0.0 == rpn:calculate("10 4 3 + 2 * - 16 5 1 - / +").
true
2> 2.0 == rpn:calculate("18 4 3 + 2 * - 2 /").
true
3> ^G, q
$ python3
>>> import(rpn)
>>> 0.0 == rpn.calculate("10 4 3 + 2 * - 16 5 1 - / +")
True
>>> 2.0 == rpn.calculate("18 4 3 + 2 * - 2 /")
True
>>> exit()
$ scalac rpn.scala
$ scala
scala> 0.0 == rpn.calculate("10 4 3 + 2 * - 16 5 1 - / +")
res0: Boolean = true
scala> 2.0 == rpn.calculate("18 4 3 + 2 * - 2 /")
res1: Boolean = true
scala> :q