Beispiel: Mergesort

Sequentieller Algorithmus:

merge :: Ord a => [a] -> [a] -> [a]
split :: [a] -> ([a],[a])
msort :: Ord a => [a] -> [a]
msort [] = [] ; msort [x] = [x] ; msort xs = 
    let ( here, there ) = split xs
        mshere  = msort here
        msthere = msort there
    in  merge mshere msthere
Strategie-Annotation in msort,

dabei Auswertung der Teilresultate erzwingen.


Johannes Waldmann 2011-06-29