module Exercise_7 where import Data.List import Data.Ord import Data.Function import Control.Applicative import Control.Arrow {-WETT-} trancl :: Eq a => [(Integer,(a,a))] -> [(Integer,(a,a))] trancl r = if r == r' then r else trancl r' where r' = nubBy ((==) `on` snd) . sortBy (comparing fst) $ r ++ [(m + n, (fst x, snd y)) | (m, x) <- r, (n, y) <- r, snd x == fst y] {-TTEW-}