stack
Stack Data Structure
Calling Sequence
Parameters
Description
Examples
stack[new]()
stack[new](x1, ..., xn)
stack[push](x, s)
stack[pop](s)
stack[empty](s)
stack[top](s)
stack[depth](s)
s
-
x, x[i]
values to be inserted into the stack
Important: The stack command has been deprecated. Use the superseding command DEQueue instead.
The call stack[new]() returns an empty stack. The call stack[new](x1, ..., xn) returns a stack with the values x1, ..., xn on the stack with x1 on the top of the stack.
The call stack[push](x, s) puts x on the top of the stack s while stack[pop](s) returns (and removes) the top element from the stack.
The call stack[empty](s) returns true if the stack s is empty, and false if it is not empty.
Additionally, stack[top](s) returns the top element of the stack (but does not remove it) and stack[depth](s) returns the number of elements in the stack.
An object-oriented stack implementation is available via the Stack constructor.
s≔stacknew⁡greg,tony,bruno,michael:
stackpush⁡stefan,s
stefan
stackdepth⁡s
5
stacktop⁡s
whilenotstackempty⁡sdostackpop⁡senddo
greg
See Also
DEQueue
priqueue
Stack
Download Help Document