Urple.java12.13 KB

The HP-48 programming language, RPL, and its variants User RPL and System RPL are very dear to me. I spent hundreds, thousands, possibly billions of hours programming my two HP-48GX calculators back in high school.

RPL is unlike any programming language you have ever programmed in. There is somewhat of an introduction at the HP Museum, so I won't attempt to detail it. Basically, you have a stack, and your program looks like:

« 1 X SQ SWAP - SQRT »

...which would calculate √(x²-1). Here, 1 gets pushed onto the stack, then the value of x (you could single-quote x if you wanted to delay evaluation). Then SQ squares the value on the top of the stack. Next, SWAP swaps the top two values on the stack, so that the next step subtracts 1 from x² instead of the other way 'round. Then SQRT takes the square root of that.

Urple is a very poor, minimal Java implementation of some of the basic methods of User RPL. It doesn't even have conditionals and loops yet. It's basically just a calculator like the venerable Unix dc. If you want a real RPN calculator, check out Orpie—fantastic stuff!