diff options
| author | Matthias Wisniowski <matthias.wisniowski@gmail.com> | 2012-05-30 00:12:10 +0200 |
|---|---|---|
| committer | Matthias Wisniowski <matthias.wisniowski@gmail.com> | 2012-05-30 00:12:10 +0200 |
| commit | 78a4651eca476bbba1d916140f0054c49a02f980 (patch) | |
| tree | b80f396e7c3b8ac2244d133a7ae3c2fcf6135156 /AufgabeFFP8.hs | |
| parent | bf712038d85069afcc8bc063f40caca466ca81b6 (diff) | |
| parent | 46e188c83e0ca7456420f4010b5b7b0422dc6acd (diff) | |
| download | ffp-78a4651eca476bbba1d916140f0054c49a02f980.tar.gz ffp-78a4651eca476bbba1d916140f0054c49a02f980.tar.bz2 ffp-78a4651eca476bbba1d916140f0054c49a02f980.zip | |
Merge branch 'master' of ssh://git.manuel.mausz.at:2211/ffp
Conflicts:
AufgabeFFP8.hs
Diffstat (limited to 'AufgabeFFP8.hs')
| -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 | ||
