The basis of RPN - Chapter 3

the Stack manipulation functions

Here is a list of common stack function.

Let's imagine you have these 3 numbers in the stack : 111 , 200 and 345.
Your stack looks like this :
4:
3:  111
2:  200
1:  345
Now lets see what's happens when we use some stack functions :
Starting stack function used resluting stack notes
4:
3:  111
2:  200
1:  345
DUP
4:  111
3:  200
2:  345
1:  345
it dupplicate the first item of the stack
4:
3:  111
2:  200
1:  345
DROP
4:
3:  
2:  111
1:  200
it remove the first ietm. see CLEAR to remove all
4:
3:  111
2:  200
1:  345
DUP2
5:  111
4:  200
3:  345
2:  200
1:  345
very interresting to dup the 2 first item
4:
3:  111
2:  200
1:  345
OVER
4:  111
3:  200
2:  345
1:  200
it copy the second item
4:
3:  111
2:  200
1:  345
SWAP
4:
3:  111
2:  345
1:  200
it brind you the second item by swaping it with the first one
4:
3:  111
2:  200
1:  345
ROT
4:
3:  200
2:  345
1:  111
it moves the 3 last items...
Of course, there are other stack manipulation function like PICK, DEPTH, ROLLD... but at first stages you better focus on the one you have on this page.


These stack operations are very powerfull, and this makes the strengh of RPN based calculator.
for example, just perform a DUP2 before making an operation, then you will copy the 2 first stack value...


PLEASE NOTE THAT IT's NOT FINISHED YET - UNDER CONSTRUCTION
You will have to be patient, I've my own work, and when I'm back at home, I've my familly...
If you want to help me, you are really wellcome.
Spetember, 5th