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 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'AufgabeFFP5.hs') 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 -- cgit v1.2.3