# HG changeset patch # User Markus Kaiser # Date 1352916802 -3600 # Node ID 8496af3b866bd15af17246329274788341716f71 # Parent a721abd5a1354a4c45e8dab11378a50c6d1c1321 add G5.3 and G5.4 definitions diff -r a721abd5a135 -r 8496af3b866b exercises/src/Exercise_5.hs --- a/exercises/src/Exercise_5.hs Wed Nov 14 18:33:30 2012 +0100 +++ b/exercises/src/Exercise_5.hs Wed Nov 14 19:13:22 2012 +0100 @@ -49,8 +49,8 @@ partition_rec p xs = undefined -partition_foldl :: (a -> Bool) -> [a] -> ([a], [a]) -partition_foldl p xs = undefined +partition_foldr :: (a -> Bool) -> [a] -> ([a], [a]) +partition_foldr p xs = undefined partition_filter :: (a -> Bool) -> [a] -> ([a], [a]) @@ -63,6 +63,34 @@ {---------------------------------------------------------------------} +{- Aufgabe G5.3 -} + +lambda_1 = (\xs -> foldr (++) [] (map (\x -> [x]) xs)) +lambda_2 = (\gg xx yy -> head (tail (zipWith gg [ xx , xx ] [ yy , yy ]))) + + + +{---------------------------------------------------------------------} +{- Aufgabe G5.4 -} + +zeros :: [Int] +zeros = 0 : zeros + + +length' :: [a] -> Int +length' [] = 0 +length' (_:xs) = 1 + length' xs + + +h :: Integer -> Integer -> Integer +h m n + | m == n = 0 + | m < n = h m (n - 1) + | m >= n = h n m + 1 + + + +{---------------------------------------------------------------------} {- Aufgabe H5.1 -} fixpoint :: (a -> a -> Bool) -> (a -> a) -> a -> a