summaryrefslogtreecommitdiffstats
path: root/AufgabeFFP5.hs
diff options
context:
space:
mode:
Diffstat (limited to 'AufgabeFFP5.hs')
-rw-r--r--AufgabeFFP5.hs19
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
100miIndiv :: [a] -> Bool
101miIndiv a = length a <= 1
102
103miSolve :: (Ix a, Show a) => (b -> Bool) -> [(a,b)] -> [(a,b)]
104miSolve wf [(a,b)]
105 | wf b = [(a,b)]
106 | otherwise = []
107
108miDivide :: [a] -> [[a]]
109miDivide (x:xs) = [[x], xs]
110
111miCombine :: [a] -> [[a]] -> [a]
112miCombine _ [] = error "No matching index"
113miCombine a (x:xs)
114 | null x = miCombine a xs
115 | otherwise = [head x]
116
117minIndex :: (Ix a, Show a) => Array a b -> (b -> Bool) -> a
118minIndex a wf = fst $ head $ divideAndConquer miIndiv (miSolve wf) miDivide miCombine $ assocs a \ No newline at end of file