changeset 12:8496af3b866b

add G5.3 and G5.4 definitions
author Markus Kaiser <markus.kaiser@in.tum.de>
date Wed, 14 Nov 2012 19:13:22 +0100
parents a721abd5a135
children 8cc37c82619c
files exercises/src/Exercise_5.hs
diffstat 1 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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