changeset 11:a721abd5a135

week 5
author Markus Kaiser <markus.kaiser@in.tum.de>
date Wed, 14 Nov 2012 18:33:30 +0100
parents 50f08a46ea10
children 8496af3b866b
files blatt5.pdf exercises/src/Exercise_5.hs
diffstat 2 files changed, 115 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
Binary file blatt5.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exercises/src/Exercise_5.hs	Wed Nov 14 18:33:30 2012 +0100
@@ -0,0 +1,115 @@
+module Exercise_5 where
+import Data.Maybe
+
+{- Library DO NOT CHANGE -}
+type State = Integer
+type DA = (State, State -> Char -> State, State -> Bool)
+type ListDA = (State, [((State, Char), State)], [State])
+
+a :: DA
+a = (0, delta, (==1))
+  where
+    delta 0 'a' = 1
+    delta 1 'a' = 1
+    delta 2 'a' = 1
+    delta 0 'b' = 2
+    delta 1 'b' = 2
+    delta 2 'b' = 2
+
+toDA :: ListDA -> DA
+toDA (start, delta, final) = (start, deltaFun delta, (`elem` final))
+  where deltaFun dl = curry (fromMaybe 0 . flip lookup dl)
+{- End Library -}
+
+
+{---------------------------------------------------------------------}
+{- Aufgabe G5.1 -}
+
+iter :: Int -> (a -> a) -> a -> a
+iter n f x = undefined
+
+
+pow :: Int -> Int -> Int
+pow n k = undefined
+
+
+drop' :: Int -> [a] -> [a]
+drop' n xs = undefined
+
+
+replicate' :: Int -> a -> [a]
+replicate' n x = undefined
+
+
+
+{---------------------------------------------------------------------}
+{- Aufgabe G5.2 -}
+
+partition_rec :: (a -> Bool) -> [a] -> ([a], [a])
+partition_rec p xs = undefined
+
+
+partition_foldl :: (a -> Bool) -> [a] -> ([a], [a])
+partition_foldl p xs = undefined
+
+
+partition_filter :: (a -> Bool) -> [a] -> ([a], [a])
+partition_filter p xs = undefined
+
+
+zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c]
+zipWith' f xs ys = undefined
+
+
+
+{---------------------------------------------------------------------}
+{- Aufgabe H5.1 -}
+
+fixpoint :: (a -> a -> Bool) -> (a -> a) -> a -> a
+fixpoint = undefined
+
+
+cents :: [Integer] -> [Integer]
+cents = undefined
+
+
+trancl :: [(Integer, Integer)] -> [(Integer, Integer)]
+trancl = undefined
+
+
+
+{---------------------------------------------------------------------}
+{- Aufgabe H5.2 -}
+
+advance :: DA -> State -> String -> State
+advance = undefined
+
+
+prop_advance_empty :: ListDA -> State -> Bool
+prop_advance_empty = undefined
+
+
+prop_advance_single :: ListDA -> State -> Char -> Bool
+prop_advance_single = undefined
+
+
+prop_advance_concat :: ListDA -> State -> String -> String -> Bool
+prop_advance_concat = undefined
+
+
+accept :: DA -> String -> Bool
+accept = undefined
+
+
+reachableStates :: DA -> State -> [Char] -> [State]
+reachableStates = undefined
+
+
+
+{---------------------------------------------------------------------}
+{- Aufgabe H5.3 -}
+
+{-WETT-}
+quasiSubseq :: Eq a => [a] -> [a] -> Bool
+quasiSubseq xs ys = undefined
+{-TTEW-}