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
trClos :: Ord a => Rel a -> Rel a
trClos xs = keepSearching (sort.nub) xs
keepSearching :: Ord a => Rel a -> Rel a -> Rel a
keepSearching rel1 rel2 = if (nub(rel1++(rel1@@rel2)) == nub(rel1++rel2))
then nub(rel1++rel2)
else keepSearching (rel1++(rel1@@rel2)) rel2
Too expensive. It does too much steps. Better:
trClos :: Ord a => Rel a -> Rel a
trClos xs = keepSearching xs xs
keepSearching :: Ord a => Rel a -> Rel a
keepSearching rel1 = if ((sort.nub)(rel1++(rel1@@rel1)) == rel1)
then rel1
else keepSearching ((sort.nub) (rel1++(rel1@@rel1)))
Ex. 7
-- Test trClos
prop_trClos :: Ord a => Rel a -> Bool
prop_trClos r = let rclos = trClos r
transitiveChecks :: [Bool]
transitiveChecks = [ ((a, c) `elem` rclos) | (a, b) <- rclos, (c, d) <- rclos, b == c ]
in (nub r) `isSublist` (nub rclos) -- Check if r is subset of rclos
&& foldr (&&) True transitiveChecks -- Check transitive property of rclos
must become
prop_trClos :: Ord a => Rel a -> Bool
prop_trClos r = let rclos = trClos r
transitiveChecks :: [Bool]
transitiveChecks = [ ((a, d) `elem` rclos) | (a, b) <- rclos, (c, d) <- rclos, b == c ]
in (nub r) `isSublist` (nub rclos) -- Check if r is subset of rclos
&& foldr (&&) True transitiveChecks -- Check transitive property of rclos
The text was updated successfully, but these errors were encountered:
Ex. 6
Too expensive. It does too much steps. Better:
Ex. 7
must become
The text was updated successfully, but these errors were encountered: