An rpn calculator using no explicit stack, only recursion and function-passing (golang)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml
AUTHORS
LICENSE
README.md
rpn.go

README.md

rpn Build Status

An rpn calculator using no explicit stack, only recursion and function-passing (golang)

usage

Values are entered in reverse polish notation (rpn) order. Values entered are stored on a stack. When an operator is entered, it reaches backwards into the stack to find its arguments, and pushes its result onto the stack. For example, to add 1 and 2, first push 1 onto the stack, then push 2, then push the "+" operator, which takes the previous two values on the stack, 1 and 2, as its arguments:
1 2 +
will result in the stack:
3

syntax

###binary operators + addition
- subtraction
* multiplication
/ division
| bitwise or
& bitwise and

###unary operators c negation
~ bitwise not
dup duplicate the value on the top of the stack
(ie, 1 dup ==> 1 1)
pop pop the top value off of the stack and discard it
swap swap the top two values on the stack
zero pop and discard all values on the stack
print print the top value on the stack

###other quit quit