Skip to content
/ rpn Public

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

License

Notifications You must be signed in to change notification settings

joshlf/rpn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages