This project is a complete, polished, but small product: A reverse polish notation calculator in the style of a unix command line tool.
It looks something like this:
It focuses on:
- Awareness of UNIX command line culture, convention, and user expectations
- Supports interactive use cases as well as programmatic use cases involving pipelines and redirection
- A tool that is pleasant, intuitive, and flexible
- A reasonably high degree of polish
You'll be happy to make this program a part of your permanent toolbox.
- A tool called
rpnwritten in python and no other dependancies. - The command line tool that operates like other UNIX command line tools.
- Packaged so it can be easily built/run on common UNIX systems (Linux, MacOS)
While developing this project, we found the following references useful:
For example, a programmer working on a low level project might expect binary and hex input/output:
$ rpn
> bin
> 0xaa55
0b1010101001010101 > 2 |
0b1010101001010111 > 1 ~ &
0b1010101001010110 >
And someone interested in factorials may expect more than the usual level of precision:
$ rpn
> 50 fact
30414093201713375576366966406747986832057064836514787179557289984 >
These are just a couple of examples. An end user should expect to fumble around with this tool and be pleasantly surprised when things "just work".
This is the command line help from our reference implementation:
USAGE:
rpn --help Show this help message
rpn Launch in interactive mode
rpn [expression] Evaluate a one-line expression
rpn help Show command reference (just runs the 'help' command)
RC FILES
~/.rpnrc is executed at startup if it exists.
~/.rpn_history contains the command history for interactive mode.
EXAMPLES
rpn 1 2 + 3 + 4 + 5 + => 15
rpn pi cos => -1
rpn => interactive mode
