module Exercise_7 where {-WETT-} trancl :: Eq a => [(Integer,(a,a))] -> [(Integer,(a,a))] trancl xs = if length xs == length ys then ys else trancl ys where ys = filterAll (reverse (filterAll (xs ++ [ (n+m,(a,c)) | (n,(a,b))<-xs, (m,(b',c))<-xs, b==b' ]))) filterAll [] = [] filterAll ((o,(d,e)):zs) | null [ o | (o',(d',e'))<-zs, d==d', e==e', o>=o' ] = (o,(d,e)):filterAll zs | otherwise = filterAll zs {-TTEW-}