module Exercise_7 where import Data.Maybe import Data.List {-WETT-} comp :: Eq b => [(Integer,(a,b))] -> [(Integer,(b,c))] -> [(Integer,(a,c))] comp [] _ = [] comp xs ys |find == [] = [] ++ comp (tail xs) ys |otherwise =(map (\x ->(fst (head xs) + (fst (ys!!x)),(((fst . snd . head)xs), (snd (snd(ys!!x))) ))) find ) ++ comp (tail xs) ys where find = findIndices (((snd.snd.head) xs ==).fst.snd) ys search' :: Eq a => [(Integer,(a,a))] -> [(Integer,(a,a))] search' [] = [] search' xs |find == [] = head xs : search' (tail xs) |otherwise = (minimum (map (\x -> fst (xs!!x)) find),snd (head xs)) : search' (xs\\(map (xs!!) find)) where find = findIndices (((snd.head) xs ==).snd) xs trancl :: Eq a => [(Integer,(a,a))] -> [(Integer,(a,a))] trancl ur |ur == temp = ur |otherwise = trancl temp where temp = search' ( nub (ur++(comp ur ur))) {-TTEW-}