diff options
| -rw-r--r-- | AufgabeFFP8.hs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/AufgabeFFP8.hs b/AufgabeFFP8.hs index 2747597..436e6cb 100644 --- a/AufgabeFFP8.hs +++ b/AufgabeFFP8.hs | |||
| @@ -115,5 +115,47 @@ minfree_bhof xs = head $ divideAndConquer (b_indiv (length xs)) b_solve (b_divid | |||
| 115 | where b = 1+(length xs) `div` 2 | 115 | where b = 1+(length xs) `div` 2 |
| 116 | 116 | ||
| 117 | -- minfree refined daq higher order | 117 | -- minfree refined daq higher order |
| 118 | |||
| 118 | 119 | ||
| 120 | -- refined divide-and-conquer mittels higher order function | ||
| 121 | --minfree_rhof :: [Int] -> Int | ||
| 122 | --minfree_rhof = divideAndConquer r_indiv r_solve r_divide r_combine | ||
| 123 | -- | ||
| 124 | --r_indiv :: (Int, [Int]) -> Bool | ||
| 125 | --r_indiv (a, xs) | ||
| 119 | 126 | ||
| 127 | -- optimised divide-and-conquer mittels higher order function | ||
| 128 | --minfree_ohof :: [Int] -> Int | ||
| 129 | |||
| 130 | |||
| 131 | |||
| 132 | -- QuickCheck part | ||
| 133 | |||
| 134 | functions = [ minfree_bv, minfree_chl, minfree_col, | ||
| 135 | minfree_b, minfree_r, minfree_o, | ||
| 136 | minfree_bhof] | ||
| 137 | |||
| 138 | -- calc values of all function | ||
| 139 | calc_all :: [Int] -> [Int] | ||
| 140 | calc_all xs = [ f xs | f <- functions ] | ||
| 141 | |||
| 142 | -- check if all values of a list are the same | ||
| 143 | all_eq :: [Int] -> Bool | ||
| 144 | all_eq (x:[]) = True | ||
| 145 | all_eq (x:y:xs) | ||
| 146 | | x == y = all_eq (y:xs) | ||
| 147 | | otherwise = False | ||
| 148 | |||
| 149 | -- check if a list contains no duplicates | ||
| 150 | --no_dups :: [Int] -> Bool | ||
| 151 | --no_dups [] = True | ||
| 152 | --no_dups (x:xs) | ||
| 153 | -- | x `elem` xs = False | ||
| 154 | -- | otherwise = no_dups xs | ||
| 155 | |||
| 156 | prop_allImplsEq_a :: [Int] -> Bool | ||
| 157 | prop_allImplsEq_a xs = all_eq $ calc_all (nub xs) | ||
| 158 | |||
| 159 | -- keine negativen listenelemented durch vorbedingung entfernt | ||
| 160 | prop_allImplsEq_b :: [Int] -> Property | ||
| 161 | prop_allImplsEq_b xs = all (>=0) xs ==> all_eq $ calc_all (nub xs) \ No newline at end of file | ||
