Traversieren

data Tree a = Branch (Tree a) (Tree a)
            | Leaf a
fold :: ...
largest :: Ord a => Tree a -> a
replace_all_by :: a -> Tree a -> Tree a
replace_all_by_largest 
    :: Ord a => Tree a -> Tree a

die offensichtliche Implementierung

replace_all_by_largest t = 
    let l = largest t
    in  replace_all_by l t
durchquert den Baum zweimal.

Eine Durchquerung reicht aus!



Johannes Waldmann 2011-01-18