Mercurial > 12ws.info2
view exercises/src/Exercise_6.hs @ 14:0d15fb5d5ade
week 6
author | Markus Kaiser <markus.kaiser@in.tum.de> |
---|---|
date | Wed, 21 Nov 2012 19:45:54 +0100 |
parents | |
children | bef891fc07b4 |
line wrap: on
line source
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-}