Desgleichen für Bäume

algebraische Datentyp:
data Tree k = Leaf { key  :: k }
   | Branch { left :: Tree k
            , right :: Tree k }
Kompositum:
interface Tree<K> { }
class Leaf<K>   implements Tree<K> { 
  Leaf(E key) { .. }
}
class Branch<K> implements Tree<K> {
  Branch(Tree<K> left, Tree<K> right) { .. }
}



2009-06-15