software-engineering-amsterdam / ST2018_WG_4

0 stars 0 forks source link

Lab 4 #5

Open BertLisser opened 5 years ago

BertLisser commented 5 years ago

Ex. 3

testIntersection :: Set Int -> Set Int -> Bool
testIntersection = checkProperties [propOnlyNotInLeftSet, propNotOnlyInLeftSet, propOnlyNotInRightSet, propNotOnlyInRightSet, propInBothSets] setIntersection

testUnion :: Set Int -> Set Int -> Bool
testUnion = checkProperties [propOnlyInLeftSet, propOnlyNotInLeftSet, propOnlyInRightSet, propOnlyNotInRightSet, propInBothSets] setUnion

testDifference :: Set Int -> Set Int -> Bool
testDifference = checkProperties [propOnlyInLeftSet, propNotOnlyNotInLeftSet, propNotOnlyNotInRightSet, propNotInBothSets] setDifference

Nice original code!

Ex 6

trClos :: Ord a => Rel a -> Rel a
trClos clos
  | clos == x = sort clos
  | otherwise = trClos x
  where x = nub $ clos ++ (clos @@ clos)

This will work but does a step too much. Nicer:

trClos :: Ord a => Rel a -> Rel a
trClos clos
  | clos == x = sort clos
  | otherwise = trClos x
  where x = (sort.nub) $ clos ++ (clos @@ clos)