jctim / rpn-calc

RPN Calculator in different languages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implemented in different languages

Purposes of this repository

Erlang

Compile (via interactive shell)

$ erl

1> c(rpn).
{ok,rpn}

Compile (via command-line compiler)

$ erlc rpn.erl

Run (via interactive shell)

$ 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

Python

Run (via interactive shell)

$ 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()

Scala

Compile (via command-line compiler)

$ scalac rpn.scala 

Run (via interactive shell)

$ 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

About

RPN Calculator in different languages


Languages

Language:Python 54.1%Language:Scala 26.3%Language:Erlang 19.6%