Go backward to Concrete Stacks Go up to Top Go forward to Hiding the Representation |
type GenericListStack =
forall Item.
{emptyStack: List[Item],
push: (Item x List[Item]) -> List[Item]
pop: List[Item] x List[Item],
top: List[Item] -> Item}
value genericListStack: GenericListStack =
all[Item]
{emptyStack = nil[Item],
push = fun(a: Item, s: List[Item]) cons[Item](a,s),
pop = fun(s: List[Item]) tl[Item](s)
top = fun(s: List[Item]) hd[Item](s)}
type GenericArrayStack =
...
value genericArrayStack: GenericArrayStack =
...