# HG changeset patch # User Markus Kaiser # Date 1353523554 -3600 # Node ID 0d15fb5d5adeaf3caf570ec357da4e4c90ee7765 # Parent 8cc37c82619cf5d2f6dec58c1af9c11f9788c2f8 week 6 diff -r 8cc37c82619c -r 0d15fb5d5ade blatt6.pdf Binary file blatt6.pdf has changed diff -r 8cc37c82619c -r 0d15fb5d5ade exercises/src/Exercise_6.hs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exercises/src/Exercise_6.hs Wed Nov 21 19:45:54 2012 +0100 @@ -0,0 +1,130 @@ +module Exercise_6 where +import Data.Char +import Test.QuickCheck + +{- Library DO NOT CHANGE -} +type PairList = [(Int,Int)] +{- End Library -} + + +{---------------------------------------------------------------------} +{- Aufgabe G6.1 -} + +instance Num b => Num (a -> b) where + f + g = undefined + f - g = undefined + f * g = undefined + negate f = undefined + abs f = undefined + signum f = undefined + fromInteger x = undefined + + + +{---------------------------------------------------------------------} +{- Aufgabe G6.2 -} + +foldl' f z [] = z +foldl' f z ( x : xs ) = foldl' f ( f z x ) xs + +foldr' f z [] = z +foldr' f z ( x : xs ) = f x ( foldr' f z xs ) + + +ffoldl = foldl' . foldl' + +oo = (.).(.) + + + +{---------------------------------------------------------------------} +{- Aufgabe G6.3 -} + + +a1 = (div 5) +a2 = (`div` 5) + +b1 = (+ 7) +b2 = ((+) 7) + +c1 = map (:[]) +c2 = map ([]:) + +d1 = flip . flip +d2 = id + +e1 x y z = [x, y, z] +e2 x y z = x : y : z + + + +{---------------------------------------------------------------------} +{- Aufgabe G6.4 -} + +{- +Lemma: reverse = foldl (\xs x -> x : xs) [] + +Base case: +To show: + +Induction step: +IH: +To show: +-} + + + +{---------------------------------------------------------------------} +{- Aufgabe G6.5 -} + +f1 xs = map (\x -> x + 1) xs + +f2 xs = map (\x -> 2 * x) (map (\x -> x + 1) xs) + +f3 xs = filter (\x -> x > 1) (map (\x -> x + 1) xs) + +f4 f g x = f (g x) + +f5 f g x y = f (g x y) + +f6 f g x y z = f (g x y z) + +f7 f g h x = g (h (f x)) + + + +{---------------------------------------------------------------------} +{- Aufgabe H6.1 -} + +wellformed :: PairList -> Bool +wellformed = undefined + + +empty :: PairList +empty = undefined + + +member :: Int -> PairList -> Bool +member = undefined + + +insert :: Int -> PairList -> PairList +insert = undefined + + +union :: PairList -> PairList -> PairList +union = undefined + + +delete :: Int -> PairList -> PairList +delete = undefined + + + +{---------------------------------------------------------------------} +{- Aufgabe H6.2 -} + +{-WETT-} +anonymize :: String -> String +anonymize = undefined +{-TTEW-}