-- Umkehrfunktion nach Thompson snoc :: t -> [t] -> [t] snoc a l = l ++ [a] rev :: [t] -> [t] rev = foldr snoc [] -- Verbesserung hinsichtlich Effizienz umkehr :: [t] -> [t] umkehr = foldl (flip(:)) [] -- Suchverfahren: Ist ein Element a in einer Liste l vorhanden? such :: Eq t => t -> [t] -> Bool -- Lineare Suche such a [] = False such a l | a == b = True | otherwise = such a l binSuch :: (Ord t) => t -> [t] -> Bool -- Binärsuche binSuch a [] = False binSuch a l | a == m = True | a < m = binSuch a (take n l) | otherwise = binSuch a (drop (n+1) l) where n = length l `div` 2 m = l !! n