diff options
| author | Matthias Wisniowski <matthias.wisniowski@gmail.com> | 2012-05-06 22:24:13 +0200 |
|---|---|---|
| committer | Matthias Wisniowski <matthias.wisniowski@gmail.com> | 2012-05-06 22:24:13 +0200 |
| commit | 2eb3ebc3247656c246258fd6a078fa5801ff80f3 (patch) | |
| tree | bb10da183ca12cec493a8f0403437e3579840037 /AufgabeFFP5.hs | |
| parent | 6d5084dde0a659debb606e837e8edf06b4b534cf (diff) | |
| download | ffp-2eb3ebc3247656c246258fd6a078fa5801ff80f3.tar.gz ffp-2eb3ebc3247656c246258fd6a078fa5801ff80f3.tar.bz2 ffp-2eb3ebc3247656c246258fd6a078fa5801ff80f3.zip | |
Aufgabe 5, 4. Almost done, except testing errors
Diffstat (limited to 'AufgabeFFP5.hs')
| -rw-r--r-- | AufgabeFFP5.hs | 19 |
1 files changed, 19 insertions, 0 deletions
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 | |||
| 97 | -- 4. | 97 | -- 4. |
| 98 | ------------------------------------------------------------------------------- | 98 | ------------------------------------------------------------------------------- |
| 99 | 99 | ||
| 100 | miIndiv :: [a] -> Bool | ||
| 101 | miIndiv a = length a <= 1 | ||
| 102 | |||
| 103 | miSolve :: (Ix a, Show a) => (b -> Bool) -> [(a,b)] -> [(a,b)] | ||
| 104 | miSolve wf [(a,b)] | ||
| 105 | | wf b = [(a,b)] | ||
| 106 | | otherwise = [] | ||
| 107 | |||
| 108 | miDivide :: [a] -> [[a]] | ||
| 109 | miDivide (x:xs) = [[x], xs] | ||
| 110 | |||
| 111 | miCombine :: [a] -> [[a]] -> [a] | ||
| 112 | miCombine _ [] = error "No matching index" | ||
| 113 | miCombine a (x:xs) | ||
| 114 | | null x = miCombine a xs | ||
| 115 | | otherwise = [head x] | ||
| 116 | |||
| 117 | minIndex :: (Ix a, Show a) => Array a b -> (b -> Bool) -> a | ||
| 118 | minIndex a wf = fst $ head $ divideAndConquer miIndiv (miSolve wf) miDivide miCombine $ assocs a \ No newline at end of file | ||
