module Exercise_7 where import Data.List import Data.Tuple import Data.Function {-WETT-} trancl :: Eq a => [(Integer,(a,a))] -> [(Integer,(a,a))] trancl xs = head $ dropWhile (\x-> f x /= x) $ iterate f xs where f ys = nubBy ((==) `on` snd ) $ sortBy (compare `on` fst) $ ys ++ [(p+q,(x,t))|(p,(x,y))<-xs,(q,(z,t))<-ys,y==z] {-TTEW-}