module Exercise_7 where import Data.List import Data.Maybe import Data.Function {-WETT-} trancl :: Eq a => [(Integer,(a,a))] -> [(Integer,(a,a))] trancl xs | xs == ys = ys | otherwise = trancl ys where ys = nubBy (on (==) snd) $ sortOn fst $ xs ++ concatMap (\(ia, (fa,sa)) -> [(ia + fst b, (fa, snd $ snd b)) | b <- filter ((sa ==) . fst . snd) xs]) xs {-TTEW-}