manual:chapter6:stack:cmd_depth

Synopsis


Return the number of items present on the stack

Stack Diagram


Input Stack Output Stack
Idepth
Level 1 Level 1

Legend

Keyword type Command
Parallel list processing capabilities Group 1 Commands that cannot parallel process
Affected by flags -28 Enable RPN stack mode
-29 RPN stack depth

Description


The DEPTH command puts on the level 1 of the stack the number of elements present on it before executing the command itself.

When the stack is in RPN mode DEPTH always returns 4 or 8, depending on the selected stack depth.

Compatibility


DEPTH is not fully equivalent to its userRPL counterpart.

In particular:

  • In userRPL RPN stack mode is not supported.

Usage


Input

4:                                      
3:                                   1_m
2:                       { 'X' 'Y' 'Z' }
1:                    "This is a string"
…………………………………………………………………………………………………………
DEPTH                                   


Output

4:                                   1_m
3:                       { 'X' 'Y' 'Z' }
2:                    "This is a string"
1:                                     3
…………………………………………………………………………………………………………
                                        

Related Commands


Stack manipulation 27 5 NEW

Command Short Description
CLEAR Remove all objects from the stack
DEPTH Get the current stack depth
DROP Remove an object from the stack
DROP2 Remove two objects form the stack
DROPN Remove N objects from the stack
DUP Duplicate an object on the stack
DUP2 Duplicate two objects on the stack
DUPDUP Duplicate the same object twice on the stack
DUPN Duplicate a group of N objects
NDUPN Replicate one object N times and return N
NIP Remove object at level 2 on the stack
OVER Duplicate object at level 2 on the stack
PICK Duplicate object at position N on the stack
PICK3 Duplicate object at level 3 on the stack
ROLL Move object at level N to level 1
ROLLD Move object from level 1 to level N
ROT Move object from level 3 to level 1
SWAP Exchange objects in levels 1 and 2
UNPICK Move object from level 1 to level N.
UNROT Move object from level 1 to level 3
IFT Evaluate objects on the stack conditionally
IFTE Evaluate objects on the stack conditionally
STKPUSH Push a snapshot of the current stack on the undo stack NEW
STKPOP Pop a stack snapshot from the undo stack NEW
STKDROP Drop a snapshot from the undo stack NEW
STKPICK Copy snapshot in level N to the current stack NEW
STKDEPTH Get the depth of the undo stack NEW
  • manual/chapter6/stack/cmd_depth.txt
  • Last modified: 2021/09/19 13:28
  • by jojo1973