Skip to content
Márk Török edited this page Jul 15, 2020 · 2 revisions

Stack

create

It creates a new stack.
Precondition : it requires the name of the stack
Example : stack create fruits
Note : The created stack will be in the global scope. Under the hood it is an array.

push

It put an element to stack.
Precondition : it requires the name of the stack and the element.
Example : stack push fruits apple

erase

Removes all elements from stack.
Precondition : it requires the name of the stack.
Example : stack erase fruits

size

Returns the number of elements in the stack.
Precondition : it requires the name of the stack.
Example : stack size fruits

pop

Removes the next element from the stack.
Precondition : it requires the name of the stack.
Example : stack pop fruits

top

Returns the next element from the stack.
Precondition : it requires the name of the stack.
Example : stack top fruits

empty

Returns whether the stack is empty.
Precondition : it requires the name of the stack.
Example : stack empty fruits

destroy

It destroys the stack.
Precondition : it requires the name of the stack.
Example : stack destroy fruits

Clone this wiki locally