module Exercise_7 where import Data.List {-WETT-} comp :: Eq b => [(Integer, (a, b))] -> [(Integer, (b, c))] -> [(Integer, (a, c))] comp [] _ = [] comp ((i, (a, b)):fs) ss = (map (\(i2, (_, c)) -> (i + i2, (a, c))) (filter ((== b) . fst . snd) ss)) ++ comp fs ss trancl :: Eq a => [(Integer, (a, a))] -> [(Integer, (a, a))] trancl rs | rs == next = rs | otherwise = trancl next where all = rs ++ comp rs rs next = nub $ filter (\(i, (a, b)) -> find (\(si, (sa, sb)) -> sa == a && sb == b && si < i) all == Nothing) all {-TTEW-}