previous up next
Go backward to Combining Universal and Existential Quantification
Go up to Top
Go forward to Generic Element Types
RISC-Linz logo

Concrete Stacks

type IntListStack =
  {emptyStack: List[Int],
   push: (Int x List[Int]) -> List[Int]
   pop: List[Int] x List[Int],
   top:List[Int] -> Int}

value intListStack: IntListStack =
  {emptyStack = nil[Int],
   push = fun(a: Int, s: List[Int]) cons[Int](a,s),
   pop = fun(s: List[Int]) tl[Int](s)
   top = fun(s: List[Int]) hd[Int](s)}

type IntArrayStack =
  {emptyStack: (Array[Int] x Int),
   push: (Int x (Array[Int] x Int)) -> (Array[Int] x Int),
   pop: (Array[Int] x Int) x (Array[Int] x Int),
   top:(Array[Int] x Int) -> Int}

value intArrayStack: IntArrayStack =
  {emptyStack = (Array[Int](100), -1) ...}


Author: Wolfgang Schreiner
Last Modification: May 27, 1998

previous up next