From 427f4787cc8adbbf10d38cc58ae329e178817976 Mon Sep 17 00:00:00 2001 From: Matthias Wisniowski Date: Thu, 3 May 2012 10:13:50 +0200 Subject: Angabe 5 --- AufgabeFFP5.pdf | Bin 0 -> 39275 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 AufgabeFFP5.pdf diff --git a/AufgabeFFP5.pdf b/AufgabeFFP5.pdf new file mode 100644 index 0000000..0e741ab Binary files /dev/null and b/AufgabeFFP5.pdf differ -- cgit v1.2.3 From 1f33246d13fdc722c17a3c5a10aed373848b78ec Mon Sep 17 00:00:00 2001 From: Matthias Wisniowski Date: Sun, 6 May 2012 15:56:23 +0200 Subject: Aufgabe 5, 1 --- AufgabeFFP5.hs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ TestAufgabeFFP5.hs | 22 ++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 AufgabeFFP5.hs create mode 100644 TestAufgabeFFP5.hs diff --git a/AufgabeFFP5.hs b/AufgabeFFP5.hs new file mode 100644 index 0000000..d84307c --- /dev/null +++ b/AufgabeFFP5.hs @@ -0,0 +1,50 @@ +module AufgabeFFP5 +where + +import Data.Array + +newtype Table a b = Tbl (Array b a) + deriving Show + +newTable :: (Ix b) => [(b, a)] -> Table a b +newTable l = Tbl (array (lo, hi) l) + where + indices = map fst l + lo = minimum indices + hi = maximum indices + +findTable :: (Ix b) => Table a b -> b -> a +findTable (Tbl a) i = a ! i + +updTable :: (Ix b) => (b, a) -> Table a b -> Table a b +updTable p@(i, x) (Tbl a) = Tbl (a // [p]) + +dynamic :: (Ix coord) => (Table entry coord -> coord -> entry) -> (coord, coord) -> (Table entry coord) +dynamic compute bnds = t + where + t = newTable (map (\coord -> (coord, compute t coord)) (range bnds)) + +------------------------------------------------------------------------------- + +bndsAS :: Array Int Int -> ((Int, Int), (Int, Int)) +bndsAS a = ((l,l), (h,h)) + where + (l,h) = bounds a + +compAS :: Array Int Int -> Table Int (Int, Int) -> (Int, Int) -> Int +compAS a t (i,j) + | i == j = a ! j + | i (Int, Int) -> Int +asDyn a (i,j) = findTable t (i,j) + where + t = dynamic (compAS a) (bndsAS a) + +-- maximum function for tables +tblMax :: Table Int (Int,Int) -> Int +tblMax (Tbl a) = maximum $ elems a + +mas :: Array Int Int -> Int +mas a = tblMax $ dynamic (compAS a) (bndsAS a) diff --git a/TestAufgabeFFP5.hs b/TestAufgabeFFP5.hs new file mode 100644 index 0000000..03cd00b --- /dev/null +++ b/TestAufgabeFFP5.hs @@ -0,0 +1,22 @@ +module Main where + +import Test.HUnit +import Control.Monad +import Data.Array +import AufgabeFFP5 + +cases1 = TestLabel "mas" $ TestList [ + TestCase $ assertEqual "exercise example" + 12 + (mas $ array (1,9) [(1,3),(2,(-5)),(3,0),(4,9),(5,2),(6,(-1)),(7,2),(8,(-5)),(9,1)]), + TestCase $ assertEqual "short list" + 21 + (mas $ array (1,6) [(1, (-3)), (2, 1), (3, 10), (4, (-5)), (5, 8), (6, 7)]) + ] + +tests :: [Test] +tests = [cases1] + +main = do + forM tests $ \test -> + runTestTT test -- cgit v1.2.3 From 6d5084dde0a659debb606e837e8edf06b4b534cf Mon Sep 17 00:00:00 2001 From: Matthias Wisniowski Date: Sun, 6 May 2012 19:22:14 +0200 Subject: Aufgabe 5, 1-3 --- AufgabeFFP5.hs | 63 ++++++++++++++++++++++++++++++++++++++++++------ TestAufgabeFFP5.hs | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 122 insertions(+), 12 deletions(-) diff --git a/AufgabeFFP5.hs b/AufgabeFFP5.hs index d84307c..c528be4 100644 --- a/AufgabeFFP5.hs +++ b/AufgabeFFP5.hs @@ -25,26 +25,75 @@ dynamic compute bnds = t t = newTable (map (\coord -> (coord, compute t coord)) (range bnds)) ------------------------------------------------------------------------------- +-- 1. +------------------------------------------------------------------------------- bndsAS :: Array Int Int -> ((Int, Int), (Int, Int)) bndsAS a = ((l,l), (h,h)) where (l,h) = bounds a +-- fill the table. Lower half below diagonal not necessary +-- but filled with the symmetric value compAS :: Array Int Int -> Table Int (Int, Int) -> (Int, Int) -> Int compAS a t (i,j) | i == j = a ! j | i (Int, Int) -> Int -asDyn a (i,j) = findTable t (i,j) - where - t = dynamic (compAS a) (bndsAS a) +-- computes table for array +asTbl :: Array Int Int -> Table Int (Int, Int) +asTbl a = dynamic (compAS a) (bndsAS a) + -- maximum function for tables -tblMax :: Table Int (Int,Int) -> Int +tblMax :: (Ord a, Ix b) => Table a b -> a tblMax (Tbl a) = maximum $ elems a +-- maximum of the array's distance-sums mas :: Array Int Int -> Int -mas a = tblMax $ dynamic (compAS a) (bndsAS a) +mas a = tblMax $ asTbl a + +------------------------------------------------------------------------------- +-- 2. +------------------------------------------------------------------------------- + +-- all indices where the value equals to the maximum distance-sum +amas :: Array Int Int -> [(Int, Int)] +amas a = [(i,j) | ((i,j),v) <- (assocs array), i<=j, v>=m] + where + t@(Tbl array) = asTbl a + m = tblMax t + +------------------------------------------------------------------------------- +-- 3. +------------------------------------------------------------------------------- + +-- computes index with maximum index-difference +maxL :: [(Int, Int)] -> (Int, Int) +maxL [] = error "maximum of empty list" +maxL [x] = x +maxL (x:xs) + | l x >= l maxTail = x + | otherwise = maxTail + where + l (x,y) = y-x + maxTail = maxL xs + +-- index with maximum distance-sum and maximum index-difference +lmas :: Array Int Int -> (Int, Int) +lmas a = maxL $ amas a + +------------------------------------------------------------------------------- + +divideAndConquer :: (p->Bool) -> (p->s) -> (p->[p]) -> (p->[s]->s) -> p -> s +divideAndConquer indiv solve divide combine initPb = dAC initPb + where + dAC pb + | indiv pb = solve pb + | otherwise = combine pb (map dAC (divide pb)) + + +------------------------------------------------------------------------------- +-- 4. +------------------------------------------------------------------------------- + diff --git a/TestAufgabeFFP5.hs b/TestAufgabeFFP5.hs index 03cd00b..256c1ea 100644 --- a/TestAufgabeFFP5.hs +++ b/TestAufgabeFFP5.hs @@ -5,17 +5,78 @@ import Control.Monad import Data.Array import AufgabeFFP5 +a :: Array Int Int +a = array (1,9) [(1,3),(2,(-5)),(3,0),(4,9),(5,2),(6,(-1)),(7,2),(8,(-5)),(9,1)] + +b :: Array Int Int +b = array (1,9) [(1,3),(2,(-1)),(3,(-2)),(4,9),(5,2),(6,(-1)),(7,2),(8,0),(9,(-1))] + +c :: Array Int Int +c = array (1,5) [(1,2),(2,3),(3,(-10)),(4,1),(5,4)] + +d :: Array Int Int +d = array (1,6) [(1, (-3)), (2, 1), (3, 10), (4, (-5)), (5, 8), (6, 7)] + +minA :: Array Int Int +minA = array (0,0) [(0,0)] + cases1 = TestLabel "mas" $ TestList [ - TestCase $ assertEqual "exercise example" + TestCase $ assertEqual "mas a" 12 - (mas $ array (1,9) [(1,3),(2,(-5)),(3,0),(4,9),(5,2),(6,(-1)),(7,2),(8,(-5)),(9,1)]), - TestCase $ assertEqual "short list" + (mas a), + TestCase $ assertEqual "mas b" + 12 + (mas b), + TestCase $ assertEqual "mas c" + 5 + (mas c), + TestCase $ assertEqual "mas d" 21 - (mas $ array (1,6) [(1, (-3)), (2, 1), (3, 10), (4, (-5)), (5, 8), (6, 7)]) + (mas d), + TestCase $ assertEqual "mas minA" + 0 + (mas minA) + ] + +cases2 = TestLabel "amas" $ TestList [ + TestCase $ assertEqual "amas a" + [(3,7), (4,7)] + (amas a), + TestCase $ assertEqual "amas b" + [(1,7),(1,8),(4,7),(4,8)] + (amas b), + TestCase $ assertEqual "amas c" + [(1,2),(4,5)] + (amas c), + TestCase $ assertEqual "amas d" + [(2,6)] + (amas d), + TestCase $ assertEqual "amas minA" + [(0,0)] + (amas minA) ] + +cases3 = TestLabel "lmas" $ TestList [ + TestCase $ assertEqual "lmas a" + (3,7) + (lmas a), + TestCase $ assertEqual "lmas b" + (1,8) + (lmas b), + TestCase $ assertEqual "lmas c" + (1,2) + (lmas c), + TestCase $ assertEqual "lmas d" + (2,6) + (lmas d), + TestCase $ assertEqual "lmas minA" + (0,0) + (lmas minA) + ] + tests :: [Test] -tests = [cases1] +tests = [cases1, cases2, cases3] main = do forM tests $ \test -> -- cgit v1.2.3 From 2eb3ebc3247656c246258fd6a078fa5801ff80f3 Mon Sep 17 00:00:00 2001 From: Matthias Wisniowski Date: Sun, 6 May 2012 22:24:13 +0200 Subject: Aufgabe 5, 4. Almost done, except testing errors --- AufgabeFFP5.hs | 19 +++++++++++++++++++ TestAufgabeFFP5.hs | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/AufgabeFFP5.hs b/AufgabeFFP5.hs index c528be4..3fb926c 100644 --- a/AufgabeFFP5.hs +++ b/AufgabeFFP5.hs @@ -97,3 +97,22 @@ divideAndConquer indiv solve divide combine initPb = dAC initPb -- 4. ------------------------------------------------------------------------------- +miIndiv :: [a] -> Bool +miIndiv a = length a <= 1 + +miSolve :: (Ix a, Show a) => (b -> Bool) -> [(a,b)] -> [(a,b)] +miSolve wf [(a,b)] + | wf b = [(a,b)] + | otherwise = [] + +miDivide :: [a] -> [[a]] +miDivide (x:xs) = [[x], xs] + +miCombine :: [a] -> [[a]] -> [a] +miCombine _ [] = error "No matching index" +miCombine a (x:xs) + | null x = miCombine a xs + | otherwise = [head x] + +minIndex :: (Ix a, Show a) => Array a b -> (b -> Bool) -> a +minIndex a wf = fst $ head $ divideAndConquer miIndiv (miSolve wf) miDivide miCombine $ assocs a \ No newline at end of file diff --git a/TestAufgabeFFP5.hs b/TestAufgabeFFP5.hs index 256c1ea..eaace62 100644 --- a/TestAufgabeFFP5.hs +++ b/TestAufgabeFFP5.hs @@ -20,6 +20,11 @@ d = array (1,6) [(1, (-3)), (2, 1), (3, 10), (4, (-5)), (5, 8), (6, 7)] minA :: Array Int Int minA = array (0,0) [(0,0)] +data Week = Mon | Tue | Wed | Thu | Fri | Sat | Sun deriving (Eq, Ord, Ix, Show) + +w :: Array Week String +w = array (Tue, Sat) [(Wed, "work"), (Thu, "study"), (Tue, "study"), (Fri, "chill"), (Sat, "relax")] + cases1 = TestLabel "mas" $ TestList [ TestCase $ assertEqual "mas a" 12 @@ -73,10 +78,43 @@ cases3 = TestLabel "lmas" $ TestList [ (0,0) (lmas minA) ] + +cases4 = TestLabel "minIndex" $ TestList [ + TestCase $ assertEqual "minIndex a (>5)" + 4 + (minIndex a (>5)), + TestCase $ assertEqual "minIndex a (<0)" + 2 + (minIndex a (<0)), + TestCase $ assertEqual "minIndex a (even)" + 3 + (minIndex a (even)), + TestCase $ assertEqual "minIndex b (odd)" + 1 + (minIndex b (odd)), + -- TestCase $ assertEqual "minIndex b (>100)" + -- error "No matching index" + -- (minIndex b (>100)), + TestCase $ assertEqual "minIndex w (=='relax')" + Sat + (minIndex w (=="relax")), + TestCase $ assertEqual "minIndex w (=='work')" + Wed + (minIndex w (=="work")), + TestCase $ assertEqual "minIndex w (=='chill')" + Fri + (minIndex w (=="chill")), + TestCase $ assertEqual "minIndex w (/='chill')" + Tue + (minIndex w (/="chill")) + -- TestCase $ assertEqual "minIndex w (=='swim')" + -- error "No matching index" + -- (minIndex w (=="swim")) + ] tests :: [Test] -tests = [cases1, cases2, cases3] +tests = [cases1, cases2, cases3, cases4] main = do forM tests $ \test -> -- cgit v1.2.3 From 858b0cbc8800d695ddd3797d5eccd9a4205ecc5d Mon Sep 17 00:00:00 2001 From: Matthias Wisniowski Date: Tue, 8 May 2012 09:50:20 +0200 Subject: Comments, shorter tests --- AufgabeFFP5.hs | 6 ++-- TestAufgabeFFP5.hs | 102 ++++++++++++++--------------------------------------- 2 files changed, 29 insertions(+), 79 deletions(-) diff --git a/AufgabeFFP5.hs b/AufgabeFFP5.hs index 3fb926c..78ed0fe 100644 --- a/AufgabeFFP5.hs +++ b/AufgabeFFP5.hs @@ -41,7 +41,7 @@ compAS a t (i,j) | i Table Int (Int, Int) asTbl a = dynamic (compAS a) (bndsAS a) @@ -59,10 +59,10 @@ mas a = tblMax $ asTbl a -- all indices where the value equals to the maximum distance-sum amas :: Array Int Int -> [(Int, Int)] -amas a = [(i,j) | ((i,j),v) <- (assocs array), i<=j, v>=m] +amas a = [(i,j) | ((i,j),v) <- (assocs array), i<=j, v>=maxAS] where t@(Tbl array) = asTbl a - m = tblMax t + maxAS = tblMax t ------------------------------------------------------------------------------- -- 3. diff --git a/TestAufgabeFFP5.hs b/TestAufgabeFFP5.hs index eaace62..7e0b731 100644 --- a/TestAufgabeFFP5.hs +++ b/TestAufgabeFFP5.hs @@ -25,91 +25,41 @@ data Week = Mon | Tue | Wed | Thu | Fri | Sat | Sun deriving (Eq, Ord, Ix, Show) w :: Array Week String w = array (Tue, Sat) [(Wed, "work"), (Thu, "study"), (Tue, "study"), (Fri, "chill"), (Sat, "relax")] -cases1 = TestLabel "mas" $ TestList [ - TestCase $ assertEqual "mas a" - 12 - (mas a), - TestCase $ assertEqual "mas b" - 12 - (mas b), - TestCase $ assertEqual "mas c" - 5 - (mas c), - TestCase $ assertEqual "mas d" - 21 - (mas d), - TestCase $ assertEqual "mas minA" - 0 - (mas minA) +cases1 = "mas" ~: TestList [ + "mas a" ~: 12 ~=? (mas a), + "mas b" ~: 12 ~=? (mas b), + "mas c" ~: 5 ~=? (mas c), + "mas d" ~: 21 ~=? (mas d), + "mas minA" ~: 0 ~=? (mas minA) ] cases2 = TestLabel "amas" $ TestList [ - TestCase $ assertEqual "amas a" - [(3,7), (4,7)] - (amas a), - TestCase $ assertEqual "amas b" - [(1,7),(1,8),(4,7),(4,8)] - (amas b), - TestCase $ assertEqual "amas c" - [(1,2),(4,5)] - (amas c), - TestCase $ assertEqual "amas d" - [(2,6)] - (amas d), - TestCase $ assertEqual "amas minA" - [(0,0)] - (amas minA) + "amas a" ~: [(3,7), (4,7)] ~=? (amas a), + "amas b" ~: [(1,7),(1,8),(4,7),(4,8)] ~=? (amas b), + "amas c" ~: [(1,2),(4,5)] ~=? (amas c), + "amas d" ~: [(2,6)] ~=? (amas d), + "amas minA" ~: [(0,0)] ~=? (amas minA) ] cases3 = TestLabel "lmas" $ TestList [ - TestCase $ assertEqual "lmas a" - (3,7) - (lmas a), - TestCase $ assertEqual "lmas b" - (1,8) - (lmas b), - TestCase $ assertEqual "lmas c" - (1,2) - (lmas c), - TestCase $ assertEqual "lmas d" - (2,6) - (lmas d), - TestCase $ assertEqual "lmas minA" - (0,0) - (lmas minA) + "lmas a" ~: (3,7) ~=? (lmas a), + "lmas b" ~: (1,8) ~=? (lmas b), + "lmas c" ~: (1,2) ~=? (lmas c), + "lmas d" ~: (2,6) ~=? (lmas d), + "lmas minA" ~: (0,0) ~=? (lmas minA) ] cases4 = TestLabel "minIndex" $ TestList [ - TestCase $ assertEqual "minIndex a (>5)" - 4 - (minIndex a (>5)), - TestCase $ assertEqual "minIndex a (<0)" - 2 - (minIndex a (<0)), - TestCase $ assertEqual "minIndex a (even)" - 3 - (minIndex a (even)), - TestCase $ assertEqual "minIndex b (odd)" - 1 - (minIndex b (odd)), - -- TestCase $ assertEqual "minIndex b (>100)" - -- error "No matching index" - -- (minIndex b (>100)), - TestCase $ assertEqual "minIndex w (=='relax')" - Sat - (minIndex w (=="relax")), - TestCase $ assertEqual "minIndex w (=='work')" - Wed - (minIndex w (=="work")), - TestCase $ assertEqual "minIndex w (=='chill')" - Fri - (minIndex w (=="chill")), - TestCase $ assertEqual "minIndex w (/='chill')" - Tue - (minIndex w (/="chill")) - -- TestCase $ assertEqual "minIndex w (=='swim')" - -- error "No matching index" - -- (minIndex w (=="swim")) + "minIndex a (>5)" ~: 4 ~=? (minIndex a (>5)), + "minIndex a (<0)" ~: 2 ~=? (minIndex a (<0)), + "minIndex a (even)" ~: 3 ~=? (minIndex a (even)), + "minIndex b (odd)" ~: 1 ~=? (minIndex b (odd)), + -- "minIndex b (>100)" ~: error "No matching index" ~=? (minIndex b (>100)), + "minIndex w (=='relax')" ~: Sat ~=? (minIndex w (=="relax")), + "minIndex w (=='work')" ~: Wed ~=? (minIndex w (=="work")), + "minIndex w (=='chill')" ~: Fri ~=? (minIndex w (=="chill")), + "minIndex w (/='chill')" ~: Tue ~=? (minIndex w (/="chill")) + -- "minIndex w (=='swim')" ~: error "No matching index" ~=? (minIndex w (=="swim")) ] -- cgit v1.2.3 From 52ac93c46e9f52798a2c4e472c29cc8f131e2bdd Mon Sep 17 00:00:00 2001 From: Matthias Wisniowski Date: Fri, 11 May 2012 10:33:20 +0200 Subject: =?UTF-8?q?Methoden-namen=20lt=20lva=20seite=20angepasst.=20Angabe?= =?UTF-8?q?=20f=C3=BCr=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AufgabeFFP5.hs | 8 ++++---- AufgabeFFP6.pdf | Bin 0 -> 37916 bytes 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 AufgabeFFP6.pdf diff --git a/AufgabeFFP5.hs b/AufgabeFFP5.hs index 78ed0fe..430fb22 100644 --- a/AufgabeFFP5.hs +++ b/AufgabeFFP5.hs @@ -97,18 +97,18 @@ divideAndConquer indiv solve divide combine initPb = dAC initPb -- 4. ------------------------------------------------------------------------------- -miIndiv :: [a] -> Bool +mi_indiv :: [a] -> Bool miIndiv a = length a <= 1 -miSolve :: (Ix a, Show a) => (b -> Bool) -> [(a,b)] -> [(a,b)] +mi_solve :: (Ix a, Show a) => (b -> Bool) -> [(a,b)] -> [(a,b)] miSolve wf [(a,b)] | wf b = [(a,b)] | otherwise = [] -miDivide :: [a] -> [[a]] +mi_divide :: [a] -> [[a]] miDivide (x:xs) = [[x], xs] -miCombine :: [a] -> [[a]] -> [a] +mi_combine :: [a] -> [[a]] -> [a] miCombine _ [] = error "No matching index" miCombine a (x:xs) | null x = miCombine a xs diff --git a/AufgabeFFP6.pdf b/AufgabeFFP6.pdf new file mode 100644 index 0000000..0fe111b Binary files /dev/null and b/AufgabeFFP6.pdf differ -- cgit v1.2.3 From 3cc0356cae5bc03e2331a68c3411e3df7cd222d6 Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 12 May 2012 13:42:06 +0200 Subject: fix method renaming --- AufgabeFFP5.hs | 30 +++++++++++++++--------------- TestAufgabeFFP5.hs | 7 +++---- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/AufgabeFFP5.hs b/AufgabeFFP5.hs index 430fb22..75383f7 100644 --- a/AufgabeFFP5.hs +++ b/AufgabeFFP5.hs @@ -1,8 +1,8 @@ module AufgabeFFP5 where - + import Data.Array - + newtype Table a b = Tbl (Array b a) deriving Show @@ -31,7 +31,7 @@ dynamic compute bnds = t bndsAS :: Array Int Int -> ((Int, Int), (Int, Int)) bndsAS a = ((l,l), (h,h)) where - (l,h) = bounds a + (l,h) = bounds a -- fill the table. Lower half below diagonal not necessary -- but filled with the symmetric value @@ -44,7 +44,7 @@ compAS a t (i,j) -- computes distance-sum-table for array asTbl :: Array Int Int -> Table Int (Int, Int) asTbl a = dynamic (compAS a) (bndsAS a) - + -- maximum function for tables tblMax :: (Ord a, Ix b) => Table a b -> a tblMax (Tbl a) = maximum $ elems a @@ -79,7 +79,7 @@ maxL (x:xs) l (x,y) = y-x maxTail = maxL xs --- index with maximum distance-sum and maximum index-difference +-- index with maximum distance-sum and maximum index-difference lmas :: Array Int Int -> (Int, Int) lmas a = maxL $ amas a @@ -92,27 +92,27 @@ divideAndConquer indiv solve divide combine initPb = dAC initPb | indiv pb = solve pb | otherwise = combine pb (map dAC (divide pb)) - + ------------------------------------------------------------------------------- -- 4. ------------------------------------------------------------------------------- mi_indiv :: [a] -> Bool -miIndiv a = length a <= 1 +mi_indiv a = length a <= 1 mi_solve :: (Ix a, Show a) => (b -> Bool) -> [(a,b)] -> [(a,b)] -miSolve wf [(a,b)] +mi_solve wf [(a,b)] | wf b = [(a,b)] | otherwise = [] - + mi_divide :: [a] -> [[a]] -miDivide (x:xs) = [[x], xs] +mi_divide (x:xs) = [[x], xs] mi_combine :: [a] -> [[a]] -> [a] -miCombine _ [] = error "No matching index" -miCombine a (x:xs) - | null x = miCombine a xs +mi_combine _ [] = error "No matching index" +mi_combine a (x:xs) + | null x = mi_combine a xs | otherwise = [head x] - + minIndex :: (Ix a, Show a) => Array a b -> (b -> Bool) -> a -minIndex a wf = fst $ head $ divideAndConquer miIndiv (miSolve wf) miDivide miCombine $ assocs a \ No newline at end of file +minIndex a wf = fst $ head $ divideAndConquer mi_indiv (mi_solve wf) mi_divide mi_combine $ assocs a diff --git a/TestAufgabeFFP5.hs b/TestAufgabeFFP5.hs index 7e0b731..865f503 100644 --- a/TestAufgabeFFP5.hs +++ b/TestAufgabeFFP5.hs @@ -32,7 +32,7 @@ cases1 = "mas" ~: TestList [ "mas d" ~: 21 ~=? (mas d), "mas minA" ~: 0 ~=? (mas minA) ] - + cases2 = TestLabel "amas" $ TestList [ "amas a" ~: [(3,7), (4,7)] ~=? (amas a), "amas b" ~: [(1,7),(1,8),(4,7),(4,8)] ~=? (amas b), @@ -40,7 +40,7 @@ cases2 = TestLabel "amas" $ TestList [ "amas d" ~: [(2,6)] ~=? (amas d), "amas minA" ~: [(0,0)] ~=? (amas minA) ] - + cases3 = TestLabel "lmas" $ TestList [ "lmas a" ~: (3,7) ~=? (lmas a), "lmas b" ~: (1,8) ~=? (lmas b), @@ -48,7 +48,7 @@ cases3 = TestLabel "lmas" $ TestList [ "lmas d" ~: (2,6) ~=? (lmas d), "lmas minA" ~: (0,0) ~=? (lmas minA) ] - + cases4 = TestLabel "minIndex" $ TestList [ "minIndex a (>5)" ~: 4 ~=? (minIndex a (>5)), "minIndex a (<0)" ~: 2 ~=? (minIndex a (<0)), @@ -62,7 +62,6 @@ cases4 = TestLabel "minIndex" $ TestList [ -- "minIndex w (=='swim')" ~: error "No matching index" ~=? (minIndex w (=="swim")) ] - tests :: [Test] tests = [cases1, cases2, cases3, cases4] -- cgit v1.2.3