module Exercise_7 where import Data.List import Data.Function import Data.Ord {-WETT-} trancl :: Eq a => [(Integer,(a,a))] -> [(Integer,(a,a))] trancl r = if r == new then r else trancl new where new = nubBy ((==) `on` snd) $ sortBy (comparing fst) $ r ++ [(c1+c2, (a, d)) | (c1, (a, b)) <- r, (c2, (c, d)) <- r, b == c] {-TTEW-}