Halcyon Calc - Working With The Stack

This document will build on the information from the section about the stack in the Working With The UI guide. However, that document was more about navigating the stack. This document is about manipulating the stack which is very important for proficient use of an RPN calculator.

Some of the best tools for working with the stack allow you to recover from mistakes. If you push something onto the stack which you didn't want or maybe you don't need that item on the stack any longer, use the "Drop" button to remove the item from the top of the stack. The "Drop" button executes the DROP operation so you can refer to the reference documentation for the operation for more information. Maybe the stack has many items on it and you want to clear the whole stack. You could press "Drop" multiple times but a faster way to accomplish that is the press the "■Clear" button. That button will execute the CLEAR operation and the stack will be empty after executing it.

Maybe you have performed an operation by accident and you would like the previous values back. You can press the "■Undo" button and the stack will be returned back to the state it was in prior to the previous operation. You cannot undo multiple operations, just the most recent operation. An alternative is to press the "■Last" button which will push onto the stack the arguments passed in to the most recent operation. The "■Last" button executes the LAST and allows you to preserve the result of the previous operation and get its arguments back onto the stack.

Often you want to copy the item at the top of the stack. That allows you to preserve that value and perform an operation on it. To copy the item from the top of the stack, you can use the DUP operation from the Stack menu. After executing that operation, a copy of the item on the top of the stack will be pushed, leaving two instances of that item at the top two positions on the stack. However, as a shortcut, you can press the "Enter" button with nothing on the command line which will execute the DUP operation.

Many times you will find the the item just below the top of the stack is the one you want to operate on next. You could "Drop" the item at the top of the stack but what if you want to preserve that item? In that case, you can press the "Swap" button. The "Swap" button executes the SWAP operation and will pop the top two items and then push them back on in reverse order.

What if the item you want to access is not next to the top? In that case you can use the "■Roll" button. Push the number of the item you want to retrieve. Imagine you have the numbers 50, 30 and 20 on the stack and 50 is the top of the stack, 30 below that and 20 next. If you want 20 to be on the top of the stack, push "3" onto the stack and press the "■Roll" button. That will execute the ROLL operation and leave the stack with 20 at the top, following by 50 and finally 30.

There are many more operations which you can use to manipulate the stack but these are the most frequently used. For more information about stack operations, check the Stack menu.