Go backward to Concrete Stacks
Go up to Top
Go forward to Hiding the Representation

Generic Element Types

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 =
   ...


Wolfgang.Schreiner@risc.uni-linz.ac.at
Id: understand.tex,v 1.1 1996/06/12 09:38:21 schreine Exp schreine

Prev Up Next