Next Previous Contents

8. Stack manipulation commands

8.1 The dup command

This command makes a copy of the number in level one.

Examples:

> 11 22
[ 2]                        11
[ 1]                        22
> dup
[ 3]                        11
[ 2]                        22
[ 1]                        22

8.2 The dup2 command

This command makes copies of the numbers in levels one and two.

Examples:

> 11 22
[ 2]                        11
[ 1]                        22
> dup2
[ 4]                        11
[ 3]                        22
[ 2]                        11
[ 1]                        22

8.3 The dupn command

This command takes a number as argument. Only the integer part of that number is considered. It makes copies of n (given as argument) stack elements.

Examples:

> 11 22 33 44
[ 4]                        11
[ 3]                        22
[ 2]                        33
[ 1]                        44
> 4 dupn
[ 8]                        11
[ 7]                        22
[ 6]                        33
[ 5]                        44
[ 4]                        11
[ 3]                        22
[ 2]                        33
[ 1]                        44

8.4 The drop command

This command removes the element in level one. Caution: once dropped, there is no way to bring a number back.

Examples:

> 11 22
[ 2]                        11
[ 1]                        22
> drop
[ 1]                        11
> drop

8.5 The drop2 command

This command removes the in levels one and two. Caution: once dropped, there is no way to bring a number back.

Examples:

> 11 22 33
[ 3]                        11
[ 2]                        22
[ 1]                        33
> drop2
[ 1]                        11

8.6 The dropn command

This command removes n (in level one) elements from the stack. Caution: once dropped, there is no way to bring a number back.

Examples:

> 11 22 33 44
[ 4]                        11
[ 3]                        22
[ 2]                        33
[ 1]                        44
> 3 dropn
[ 1]                        11

8.7 The clear command

This command removes all elements from the stack. Caution: once dropped, there is no way to bring a number back.

Examples:

> 11 22 33 44
[ 4]                        11
[ 3]                        22
[ 2]                        33
[ 1]                        44
> clear

8.8 The swap command

This command swaps the elements in levels one and two, that is, the element that was in level one now is in level two, and the element that was in level two now is in level one.

Examples:

> 11 22
[ 2]                        11
[ 1]                        22
> swap
[ 2]                        22
[ 1]                        11

8.9 The over command

This command makes puts a copy of the element in level two in the stack. (Equivalent to 3 PICK.)

Examples:

> 11 22
[ 2]                        11
[ 1]                        22
> over
[ 3]                        11
[ 2]                        22
[ 1]                        11

8.10 The pick command

This command takes an argument n. It makes a copy of the element in level n+1.

Examples:

> 11 22 33 44
[ 4]                        11
[ 3]                        22
[ 2]                        33
[ 1]                        44
> 3 pick
[ 5]                        11
[ 4]                        22
[ 3]                        33
[ 2]                        44
[ 1]                        22

8.11 The rot command

This command rolls levels one, two and three upwards. The number in level three goes to level one, the number in level two goes to level three and the number in level one goes to level two. (Equivalent to 3 ROLL.)

Examples:

> 11 22 33
[ 3]                        11
[ 2]                        22
[ 1]                        33
> rot
[ 3]                        22
[ 2]                        33
[ 1]                        11

8.12 The unrot command

This command rolls levels one, two and three downwards. The number in level one goes to level three, the number in level two goes to level one and the number in level three goes to level two. (Equivalent to 3 ROLLD.)

Examples:

> 11 22 33
[ 3]                        11
[ 2]                        22
[ 1]                        33
> unrot
[ 3]                        33
[ 2]                        11
[ 1]                        22

8.13 The roll command

This command rolls levels from two to n+1 (n is in level one) upwards.

Examples:

> 11 22 33 44
[ 4]                        11
[ 3]                        22
[ 2]                        33
[ 1]                        44
> 4 roll
[ 4]                        22
[ 3]                        33
[ 2]                        44
[ 1]                        11

8.14 The rolld command

This command rolls levels from two to n+1 (n is in level one) downwards.

Examples:

> 11 22 33 44
[ 4]                        11
[ 3]                        22
[ 2]                        33
[ 1]                        44
> 4 rolld
[ 4]                        44
[ 3]                        11
[ 2]                        22
[ 1]                        33

8.15 The depth command

This command puts the number of elements in the stack in level one.

Examples:

> 11 22 33
[ 3]                        11
[ 2]                        22
[ 1]                        33
> depth
[ 4]                        11
[ 3]                        22
[ 2]                        33
[ 1]                         3


Next Previous Contents