https://github.com/bitwalker/rpncalculator
Reverse Polish Notation calculator built in Scala for a impromptu code challenge at work
https://github.com/bitwalker/rpncalculator
Last synced: about 1 year ago
JSON representation
Reverse Polish Notation calculator built in Scala for a impromptu code challenge at work
- Host: GitHub
- URL: https://github.com/bitwalker/rpncalculator
- Owner: bitwalker
- Created: 2013-07-30T21:45:22.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-12-27T20:35:17.000Z (over 11 years ago)
- Last Synced: 2025-03-21T13:12:37.247Z (about 1 year ago)
- Language: Scala
- Size: 119 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## What is this?
A small command line calculator built on scala which accepts operations in [Reverse Polish Notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation).
## Why?
Someone posted the equivalent version of this in Ruby, and asked anyone who was up for the challenge to produce their own using a language of their choice.
Since I'm not the kind of person to let an opportunity to code in Scala go by, I sat down and wrote this out after brushing up on my parser combinators.
## Usage
To run this, you'll need scala and sbt installed, which on OSX is as simple as:
```
brew install scala sbt
```
Then, from the project directory, run `sbt assembly` to produce the executable jar, and finally, to use the calculator:
```
java -jar ./target/scala-2.XX/RPNCalculator-assembly-X.X.jar "3 4 - 5 + 2 *"
```
Alternatively you can use `sbt "run \"3 4 - 5 + 2 *\""`, to compile and run the code directly using your scala installation.
Of course, you can put whatever expression you want as the argument, but the above is a simple example.