Suchbäume: Herstellen

aus (ungeordneter) Liste herstellen:

import Data.List (partition)

suchbaum :: [ Int ] -> Tree Int
suchbaum []       = Leaf
suchbaum (x : xs) =
   let ( low, high ) = partition ( < x ) xs
   in  Node { key   = x
            , left  = suchbaum low
            , right = suchbaum high
            }



Johannes Waldmann 2007-06-21