At almost all costs you should try to refactor to use shallow words. Shallow words are much easier to keep straight in your head and have performance gains. If you must, you can use deep stack words but it should be as a last resort.
Synopsis
3dup ( x1 x2 x3 -- x1 x2 x3 x1 x2 x3 )
Description
Duplicate the top triplet.
Example
> 1 2 3 3dup
stack (6) 1 2 3 1 2 3
Synopsis
dup# ( ... i -- ... ... )
Description
Duplicate the top i
values.
Example
> 1 2 3 4 5
stack (5) 1 2 3 4 5
> 5 dup#
stack (10) 1 2 3 4 5 1 2 3 4 5
Synopsis
3drop ( x1 x2 x3 -- )
Description
Drop the top triplet.
Example
> 1 2 3 4 5 6
stack (6) 1 2 3 4 5 6
> 3drop
stack (3) 1 2 3
Synopsis
drop# ( ... i -- )
Description
Drop the top i
items.
Example
> 1 2 3 4 5
stack (5) 1 2 3 4 5
> depth drop#
stack (0)
Synopsis
3over ( x1 x2 x3 x4 x5 x6 -- x1 x2 x3 x4 x5 x6 x1 x2 x3 )
Description
Copy the NOS
triplet over the TOS
triplet.
Example
> 1 2 3 4 5 6 3over
stack (9) 1 2 3 4 5 6 1 2 3
Synopsis
3rot ( x1 x2 x3 x4 x5 x6 x7 x8 x9 -- x4 x5 x6 x7 x8 x9 x1 x2 x3 )
Description
Rotate the top three triplets backward.
Example
> 1 2 3 4 5 6 7 8 9 3rot
stack (9) 4 5 6 7 8 9 1 2 3
Synopsis
3rot ( x1 x2 x3 x4 x5 x6 x7 x8 x9 -- x7 x8 x9 x1 x2 x3 x4 x5 x6 )
Description
Rotate the top three triplets forward.
Example
> 1 2 3 4 5 6 7 8 9 3rot
stack (9) 7 8 9 1 2 3 4 5 6
Synopsis
roll ( ... i -- ... )
Description
Roll (rotate, spin) the top i
items backward. Zero refers to TOS
, One refers to TOS
. Therefore, 0 roll
will do nothing. 1 roll
is the same as swap
. 2 roll
is the same as rot
. After that, there are no predefined words that accomplish the same task. Usually predefined words are a bit more efficient than a simple roll
.
Example
> 1 2 3 4 5 3 roll
stack (5) 1 5 2 3 4
Synopsis
-roll ( ... i -- ... )
Description
Roll the top i items forward.
Example
> 1 2 3 4 5 3 -roll
stack (5) 1 3 4 5 2