Mercurial > 12ws.info2
comparison exercises/src/Exercise_5.hs @ 11:a721abd5a135
week 5
author | Markus Kaiser <markus.kaiser@in.tum.de> |
---|---|
date | Wed, 14 Nov 2012 18:33:30 +0100 |
parents | |
children | 8496af3b866b |
comparison
equal
deleted
inserted
replaced
10:50f08a46ea10 | 11:a721abd5a135 |
---|---|
1 module Exercise_5 where | |
2 import Data.Maybe | |
3 | |
4 {- Library DO NOT CHANGE -} | |
5 type State = Integer | |
6 type DA = (State, State -> Char -> State, State -> Bool) | |
7 type ListDA = (State, [((State, Char), State)], [State]) | |
8 | |
9 a :: DA | |
10 a = (0, delta, (==1)) | |
11 where | |
12 delta 0 'a' = 1 | |
13 delta 1 'a' = 1 | |
14 delta 2 'a' = 1 | |
15 delta 0 'b' = 2 | |
16 delta 1 'b' = 2 | |
17 delta 2 'b' = 2 | |
18 | |
19 toDA :: ListDA -> DA | |
20 toDA (start, delta, final) = (start, deltaFun delta, (`elem` final)) | |
21 where deltaFun dl = curry (fromMaybe 0 . flip lookup dl) | |
22 {- End Library -} | |
23 | |
24 | |
25 {---------------------------------------------------------------------} | |
26 {- Aufgabe G5.1 -} | |
27 | |
28 iter :: Int -> (a -> a) -> a -> a | |
29 iter n f x = undefined | |
30 | |
31 | |
32 pow :: Int -> Int -> Int | |
33 pow n k = undefined | |
34 | |
35 | |
36 drop' :: Int -> [a] -> [a] | |
37 drop' n xs = undefined | |
38 | |
39 | |
40 replicate' :: Int -> a -> [a] | |
41 replicate' n x = undefined | |
42 | |
43 | |
44 | |
45 {---------------------------------------------------------------------} | |
46 {- Aufgabe G5.2 -} | |
47 | |
48 partition_rec :: (a -> Bool) -> [a] -> ([a], [a]) | |
49 partition_rec p xs = undefined | |
50 | |
51 | |
52 partition_foldl :: (a -> Bool) -> [a] -> ([a], [a]) | |
53 partition_foldl p xs = undefined | |
54 | |
55 | |
56 partition_filter :: (a -> Bool) -> [a] -> ([a], [a]) | |
57 partition_filter p xs = undefined | |
58 | |
59 | |
60 zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c] | |
61 zipWith' f xs ys = undefined | |
62 | |
63 | |
64 | |
65 {---------------------------------------------------------------------} | |
66 {- Aufgabe H5.1 -} | |
67 | |
68 fixpoint :: (a -> a -> Bool) -> (a -> a) -> a -> a | |
69 fixpoint = undefined | |
70 | |
71 | |
72 cents :: [Integer] -> [Integer] | |
73 cents = undefined | |
74 | |
75 | |
76 trancl :: [(Integer, Integer)] -> [(Integer, Integer)] | |
77 trancl = undefined | |
78 | |
79 | |
80 | |
81 {---------------------------------------------------------------------} | |
82 {- Aufgabe H5.2 -} | |
83 | |
84 advance :: DA -> State -> String -> State | |
85 advance = undefined | |
86 | |
87 | |
88 prop_advance_empty :: ListDA -> State -> Bool | |
89 prop_advance_empty = undefined | |
90 | |
91 | |
92 prop_advance_single :: ListDA -> State -> Char -> Bool | |
93 prop_advance_single = undefined | |
94 | |
95 | |
96 prop_advance_concat :: ListDA -> State -> String -> String -> Bool | |
97 prop_advance_concat = undefined | |
98 | |
99 | |
100 accept :: DA -> String -> Bool | |
101 accept = undefined | |
102 | |
103 | |
104 reachableStates :: DA -> State -> [Char] -> [State] | |
105 reachableStates = undefined | |
106 | |
107 | |
108 | |
109 {---------------------------------------------------------------------} | |
110 {- Aufgabe H5.3 -} | |
111 | |
112 {-WETT-} | |
113 quasiSubseq :: Eq a => [a] -> [a] -> Bool | |
114 quasiSubseq xs ys = undefined | |
115 {-TTEW-} |