Mercurial > 12ws.info2
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:8cc37c82619c | 14:0d15fb5d5ade |
---|---|
1 module Exercise_6 where | |
2 import Data.Char | |
3 import Test.QuickCheck | |
4 | |
5 {- Library DO NOT CHANGE -} | |
6 type PairList = [(Int,Int)] | |
7 {- End Library -} | |
8 | |
9 | |
10 {---------------------------------------------------------------------} | |
11 {- Aufgabe G6.1 -} | |
12 | |
13 instance Num b => Num (a -> b) where | |
14 f + g = undefined | |
15 f - g = undefined | |
16 f * g = undefined | |
17 negate f = undefined | |
18 abs f = undefined | |
19 signum f = undefined | |
20 fromInteger x = undefined | |
21 | |
22 | |
23 | |
24 {---------------------------------------------------------------------} | |
25 {- Aufgabe G6.2 -} | |
26 | |
27 foldl' f z [] = z | |
28 foldl' f z ( x : xs ) = foldl' f ( f z x ) xs | |
29 | |
30 foldr' f z [] = z | |
31 foldr' f z ( x : xs ) = f x ( foldr' f z xs ) | |
32 | |
33 | |
34 ffoldl = foldl' . foldl' | |
35 | |
36 oo = (.).(.) | |
37 | |
38 | |
39 | |
40 {---------------------------------------------------------------------} | |
41 {- Aufgabe G6.3 -} | |
42 | |
43 | |
44 a1 = (div 5) | |
45 a2 = (`div` 5) | |
46 | |
47 b1 = (+ 7) | |
48 b2 = ((+) 7) | |
49 | |
50 c1 = map (:[]) | |
51 c2 = map ([]:) | |
52 | |
53 d1 = flip . flip | |
54 d2 = id | |
55 | |
56 e1 x y z = [x, y, z] | |
57 e2 x y z = x : y : z | |
58 | |
59 | |
60 | |
61 {---------------------------------------------------------------------} | |
62 {- Aufgabe G6.4 -} | |
63 | |
64 {- | |
65 Lemma: reverse = foldl (\xs x -> x : xs) [] | |
66 | |
67 Base case: | |
68 To show: | |
69 | |
70 Induction step: | |
71 IH: | |
72 To show: | |
73 -} | |
74 | |
75 | |
76 | |
77 {---------------------------------------------------------------------} | |
78 {- Aufgabe G6.5 -} | |
79 | |
80 f1 xs = map (\x -> x + 1) xs | |
81 | |
82 f2 xs = map (\x -> 2 * x) (map (\x -> x + 1) xs) | |
83 | |
84 f3 xs = filter (\x -> x > 1) (map (\x -> x + 1) xs) | |
85 | |
86 f4 f g x = f (g x) | |
87 | |
88 f5 f g x y = f (g x y) | |
89 | |
90 f6 f g x y z = f (g x y z) | |
91 | |
92 f7 f g h x = g (h (f x)) | |
93 | |
94 | |
95 | |
96 {---------------------------------------------------------------------} | |
97 {- Aufgabe H6.1 -} | |
98 | |
99 wellformed :: PairList -> Bool | |
100 wellformed = undefined | |
101 | |
102 | |
103 empty :: PairList | |
104 empty = undefined | |
105 | |
106 | |
107 member :: Int -> PairList -> Bool | |
108 member = undefined | |
109 | |
110 | |
111 insert :: Int -> PairList -> PairList | |
112 insert = undefined | |
113 | |
114 | |
115 union :: PairList -> PairList -> PairList | |
116 union = undefined | |
117 | |
118 | |
119 delete :: Int -> PairList -> PairList | |
120 delete = undefined | |
121 | |
122 | |
123 | |
124 {---------------------------------------------------------------------} | |
125 {- Aufgabe H6.2 -} | |
126 | |
127 {-WETT-} | |
128 anonymize :: String -> String | |
129 anonymize = undefined | |
130 {-TTEW-} |