Rekursive Datentypen

data Tree = Leaf {}
    | Branch { left :: Tree, key :: Int
             , right :: Tree }
full :: Int -> Tree -- vollst. binärer Baum
full h = if h > 0 
    then Branch { left = full (h-1)
          , key = h, right = full (h-1) }
    else Leaf { }
leaves :: Tree -> Int
leaves t = case t of
    Leaf   {} -> ...
    Branch {} -> 0



Johannes Waldmann 2010-01-25