declare % Represent as records of form stack() % with the head of the list the top of the stack fun {NewStack} stack(nil) end fun {Push stack(Stck) Elem} stack(Elem | Stck) end fun {Pop stack(Stck) ?OldTop} H|T = Stck in OldTop = H stack(T) end fun {IsEmpty stack(Stck)} case Stck of nil then true else false end end