Stack

Revision as of 06:24, 20 February 2021 by Drkameleon (talk | contribs) (Replaced content with "=={{header|Arturo}}== <lang rebol>Stack: $[]-> [] pushTo: function [st val]-> 'st ++ val popStack: function [st] [ result: last st remove.index: (size s...")

Arturo

<lang rebol>Stack: $[]-> []

pushTo: function [st val]-> 'st ++ val popStack: function [st] [

   result: last st
   remove.index: (size st)-1 'st ø
   return result

] emptyStack: function [st]-> empty 'st printStack: function [st]-> print st

st: new Stack

pushTo st "one" pushTo st "two" pushTo st "three" printStack st

print popStack st printStack st

emptyStack st print ["finally:" st]</lang>

Output:
one two three 
three
one two 
finally: []