% $Id: Stack.oz,v 1.2 2007/10/22 04:21:59 leavens Exp leavens $ %% See the StackTest.oz file for the specification %% implementation \insert 'NewWrapper.oz' declare % See the similar program in section 3.7.5 of CTM local Wrap Unwrap {NewWrapper Wrap Unwrap} in fun {NewStack} {Wrap nil} end fun {Push WrappedStk X} Stk = {Unwrap WrappedStk} in {Wrap X|Stk} end fun {Pop WStk ?Top} local Stk Rest in Stk = {Unwrap WStk} Top|Rest = Stk {Wrap Rest} end end fun {IsEmpty WStk} {Unwrap WStk} == nil end end