Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --the quickcheck
- prop_polyListValue :: [Integer] -> Integer -> Bool
- prop_polyListValue [] _ = True
- prop_polyListValue pl n
- | plv == pv = True
- | otherwise = False
- where
- plv = polyListValue pl n
- pv = polyValue p n
- p = polyListToPoly pl
- --functions used in quickcheck
- --polyValue from assignment 3
- polyValue :: Poly -> Integer -> Integer
- polyValue X n = n
- polyValue (Coef x) _ = x
- polyValue (Sum x y) n = (polyValue x n) + (polyValue y n)
- polyValue (Prod x y) n = (polyValue x n) * (polyValue y n)
- polyListValue :: [Integer] -> Integer -> Integer
- polyListValue [] _ = 0
- polyListValue pl n = hormeth pl n
- where
- hormeth (x:[]) n = x
- hormeth (x:xs) n = (hormeth xs n) * n + x
- polyListToPoly :: [Integer] -> Poly
- polyListToPoly [] = (Coef 0)
- polyListToPoly (x:xs) = Sum (Prod (Coef x) (indexDegree (length xs))) (polyListToPoly xs)
- where indexDegree a =
- if a == 0 then Coef 1
- else Prod X (indexDegree (a - 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement