Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab 4 #3

Open
BertLisser opened this issue Oct 8, 2018 · 0 comments
Open

Lab 4 #3

BertLisser opened this issue Oct 8, 2018 · 0 comments

Comments

@BertLisser
Copy link

BertLisser commented Oct 8, 2018

Exercise 2 and 3
The random set generator is missing

Exercise 6

(@@) :: Eq a => Rel a -> Rel a -> Rel a
(Set r) @@ (Set s) = Set $ nub [ (x,z) | (x,y) <- r, (w,z) <- s, y == w ]

is wrong. Must be

(@@) :: Eq a => Rel a -> Rel a -> Rel a
(Set r) @@ (Set s) = Set $ sort.nub [ (x,z) | (x,y) <- r, (w,z) <- s, y == w ]

This error makes also this definition wrong

trClos :: Ord a => Rel a -> Rel a
trClos set = apprx [foldl1 unionSet (take n rs) | n <- [1..]] 
           where rs             = iterate (set @@) set
                 apprx (x:y:zs) = if x == y then x else apprx (y:zs)

The call of sort is missing

Exercise 7
The property that the transitive closure is minimal is missing.

This is a nice idea:

-- Define Rel as a Set, to keep using Set operations and to be able to use the above implemented
-- operations.

A pity that sort was forgotten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant