User Tools

Site Tools


pf:rpldocs:stack_manipulation
stack manipulation.txt
=CMD
=COMMAND swap (value value) value value
=DESC 
Swaps the order of the top two items on the stack.
=ENDDESC
=EX 
trace2(swap(1 2)) #prints '2 1'
=ENDEX
=ENDCMD

=CMD
=COMMAND dup (value) value value
=DESC 
Duplicates the item currently on the stack without removing the original item.
=ENDDESC
=EX 
trace2(42 dup) #prints '42 42'
=ENDEX
=ENDCMD

=CMD
=COMMAND dup2 (value value) value value value value
=DESC 
Duplicates the top two items currently on the stack without removing the original pair.
=ENDDESC
=EX 
trace4(42 1 dup2) #prints '42 1 42 1'
=ENDEX
=ENDCMD

=CMD
=COMMAND pop (value)
=DESC 
Removes the item at the top of the stack.
=ENDDESC
=EX 
42 pop #stack is now empty
=ENDEX
=ENDCMD

=CMD
=COMMAND ClearStack
=DESC 
Remove all items from the stack leaving it empty.
=ENDDESC
=EX 
1 2 3 ClearStack #Stack is now empty
=ENDEX
=ENDCMD

=CMD
=COMMAND StackSize value
=DESC 
Returns the number of items currently on the stack
=ENDDESC
=EX 
1 2 3 trace(StackSize) #prints '3'
=ENDEX
=ENDCMD
pf/rpldocs/stack_manipulation.txt · Last modified: 2016/10/16 17:48 by Karsten75