\ Stack--pushdown data structure built on top of a List vandys
only extensions definitions
List -> subclass: Stack
Stack -> :method push ( elem self -- ) -> add method;
Stack -> :method peek ( self -- elem ) dup List>nelem @
dup 0= abort" empty" 1- cells swap List>elems @ + @ method;
Stack -> :method pop ( self -- elem ) dup -> peek
swap List>nelem dec method;
Stack -> :method do ( arg 'fn self -- ) super-> reverseDo method;
Stack -> :method reverseDo ( arg 'fn self -- ) super-> do method;
vandys
Class Stack--a LIFO data structure
:method Stack:push The stack grows and shrinks from the tail of the List
:method Stack:peek Return element on top of stack
:method Stack:pop
:method Stack:do Because of this, we have to create the illusion that the
tail is "first" when iterating for display or otherwise
:method Stack:reverseDo If "do" is reversed, then so must "reverseDo" be...