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
Ex. 6
This is wrong code. temp is not sorted and with duplicates.
-- Transitive closure of relation, sorted and without duplicates
trClos :: Ord a => Rel a -> Rel a
trClos xs
| xs /= temp = trClos temp
| otherwise = xs
where temp = (xs `union` concat [ concat [ ([a] @@ [b]) | a <- xs, a /= b] | b <- xs])
Solution
trClos :: Ord a => Rel a -> Rel a
trClos xs
| xs /= temp = trClos temp
| otherwise = xs
where temp = (sort.nub) (xs `union` concat [ concat [ ([a] @@ [b]) | a <- xs, a /= b] | b <- xs])
The text was updated successfully, but these errors were encountered:
Ex. 6
This is wrong code.
temp
is not sorted and with duplicates.Solution
The text was updated successfully, but these errors were encountered: