diff options
author | Camil Staps | 2017-12-16 16:24:13 +0100 |
---|---|---|
committer | Camil Staps | 2017-12-16 16:24:13 +0100 |
commit | 42f92d56750ae7ad5d0c013a45c4318cd81dc1e7 (patch) | |
tree | 79b40a953168217f6004a2bf9817be0f097a7200 | |
parent | Finish(?) assignment 12 (diff) |
Remove value from cashModel; add further explanation to gastje
-rw-r--r-- | assignment-12/cashModel.icl | 14 | ||||
-rw-r--r-- | assignment-12/gastje.icl | 4 |
2 files changed, 5 insertions, 13 deletions
diff --git a/assignment-12/cashModel.icl b/assignment-12/cashModel.icl index c9dfc55..d76b357 100644 --- a/assignment-12/cashModel.icl +++ b/assignment-12/cashModel.icl @@ -109,17 +109,5 @@ where Start = test fairness where fairness :: [Product] Product -> Property - fairness ps p = value newps =.= value ps + value out + fairness ps p = euro newps =.= euro ps + euro out where (newps, out) = model ps (Rem p) - -class value a :: (a -> Real) -instance value Real where value = id -instance value [a] | value a where value = sum o map value -instance value Euro where value = \e -> toReal e.euro * 100.0 + toReal (sign e.euro * e.cent) -instance value Product where value = value o euro -instance value Action -where - value = \a -> case a of - Add p -> value p - Rem p -> ~(value p) - Pay -> 0.0 diff --git a/assignment-12/gastje.icl b/assignment-12/gastje.icl index d3b20ce..62f9238 100644 --- a/assignment-12/gastje.icl +++ b/assignment-12/gastje.icl @@ -115,6 +115,10 @@ where // This fails for 0; should be <=. If we fix that, the test does not // terminate, as there are no 1000 integers with abs i < 10. + // Another option is to use: + // holds (False ==> t) p = [{prop & bool=True} \\ prop <- holds t p] + // I.e., *do* count cases where the antecedent is False. However, that can + // give a wrong idea about the test coverage. fac :: Int -> Int fac n | n < 0 = 1 |