Return item from a stack

pop list

A list can be used to implement a stack (LIFO, a "last in, first out" stack). Use pop instruction to remove and return an item from a stack (the first item in a list) and push instruction to insert an item on a stack.


make "stos []
for [i 1 3] [push :stos :i print :stos]
print "|***|
while not empty? :stos [(print pop :stos :stos)]


[2 1]
[3 2 1]
3 [2 1]
2 [1]
1 []

See also:

push - put item on a stack

Table of Content