You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
integerSetGeneratorFromScratch :: IO (Set Int)
integerSetGeneratorFromScratch = do
n <- getRandomNatural
xs <- getRandomIntegers maxNatural
return (Set (nub xs))
-- Time spent: 1:15
instance (Arbitrary a, Eq a) => Arbitrary (Set a) where
arbitrary = do
xs <- arbitrary
return (Set (nub xs))
The function sort is missing in return (Set (nub xs)).
It must become: return (Set (sort(nub xs)))
Exercise 6
-- Transitive closure
trClos :: Ord a => Rel a -> Rel a
trClos r = until (\s -> tr s == s) tr r
where tr r = sort (nub ((r @@ r) ++ r))
will be go wrong in the first step
Solution:
-- Transitive closure
trClos' :: Ord a => Rel a -> Rel a
trClos' r = until (\s -> tr s == s) tr r
where tr r = sort (nub ((r @@ r) ++ r))
trClos :: Ord a => Rel a -> Rel a
trClos r = trClos' (sort r)
Ex 8
prop_ClosuresDifference :: Rel Int -> Bool
prop_ClosuresDifference r = symClos (trClos r') == trClos (symClos r')
where r' = nub r
the test defined in prop_ClosuresDifference must become
Exercise 2
The function
sort
is missing inreturn (Set (nub xs))
.It must become:
return (Set (sort(nub xs)))
Exercise 6
will be go wrong in the first step
Solution:
Ex 8
the test defined in
prop_ClosuresDifference
must becomeThe text was updated successfully, but these errors were encountered: