User Tools

Site Tools


pf:prpldocs:stack_manipulation

<script type="text/javascript"> function selectText(containerid) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(document.getElementById(containerid)); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(document.getElementById(containerid)); window.getSelection().addRange(range); } } </script>   <a href="#" onclick="selectText('selectable')">Select All</a><br/> Save the contents to "Stack Manipulation.txt"   <div id="selectable">

=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

</div>

pf/prpldocs/stack_manipulation.txt · Last modified: 2016/06/23 13:16 by virgilw