summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortotycro <totycro@unknown-horizons.org>2012-05-29 21:32:15 +0200
committertotycro <totycro@unknown-horizons.org>2012-05-29 21:32:15 +0200
commit5bb2754dfdd3c5a1d795b286ed5d762375e10752 (patch)
tree82d3d3f3f49675b8d8a9984c2c3848de459f16d8
parent036885a5375d0eada3b03d200fcc6353985a624b (diff)
downloadffp-5bb2754dfdd3c5a1d795b286ed5d762375e10752.tar.gz
ffp-5bb2754dfdd3c5a1d795b286ed5d762375e10752.tar.bz2
ffp-5bb2754dfdd3c5a1d795b286ed5d762375e10752.zip
quickcheck
-rw-r--r--AufgabeFFP8.hs39
1 files changed, 39 insertions, 0 deletions
diff --git a/AufgabeFFP8.hs b/AufgabeFFP8.hs
index e667654..f6d9bfd 100644
--- a/AufgabeFFP8.hs
+++ b/AufgabeFFP8.hs
@@ -82,6 +82,16 @@ minfrom_o a (n, xs)
82 m = length us 82 m = length us
83 83
84 84
85-- from slide 154
86divideAndConquer :: (p -> Bool) -> (p -> s) -> (p -> [p]) -> (p -> [s] -> s) -> p -> s
87divideAndConquer indiv solve divide combine initPb = dAC initPb
88 where
89 dAC pb
90 | indiv pb = solve pb
91 | otherwise = combine pb (map dAC (divide pb))
92
93
94
85-- basic divide-and-conquer mittels higher order function 95-- basic divide-and-conquer mittels higher order function
86--minfree_bhof :: [Int] -> Int 96--minfree_bhof :: [Int] -> Int
87 97
@@ -94,3 +104,32 @@ minfrom_o a (n, xs)
94 104
95 105
96-- QuickCheck part 106-- QuickCheck part
107
108functions = [ minfree_bv, minfree_chl, minfree_col,
109 minfree_b, minfree_r, minfree_o ]
110
111-- calc values of all function
112calc_all :: [Int] -> [Int]
113calc_all xs = [ f xs | f <- functions ]
114
115-- check if all values of a list are the same
116all_eq :: [Int] -> Bool
117all_eq (x:[]) = True
118all_eq (x:y:xs)
119 | x == y = all_eq (y:xs)
120 | otherwise = False
121
122-- check if a list contains no duplicates
123--no_dups :: [Int] -> Bool
124--no_dups [] = True
125--no_dups (x:xs)
126-- | x `elem` xs = False
127-- | otherwise = no_dups xs
128
129prop_allImplsEq_a :: [Int] -> Bool
130prop_allImplsEq_a xs = all_eq $ calc_all (nub xs)
131
132-- keine negativen listenelemented durch vorbedingung entfernt
133prop_allImplsEq_b :: [Int] -> Property
134prop_allImplsEq_b xs = all (>=0) xs ==> all_eq $ calc_all (nub xs)
135