Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ntr :: Eq a => [[a]] -> [[a]]
- ntr = foldr (\x acc -> ntr' x acc) []
- ntr' x [] = [x]
- ntr' x (y:ys) = case x `intersect` y of
- [] -> y : ntr' x ys
- _ -> (x `union` y) : ys
- test = [[(1,2),(1,3),(2,1)],[(1,2),(1,3),(2,3)],[(1,2),(2,1)],[(1,3),(2,3),(3,2)],[(2,3),(3,2),(4,2)],[(2,5),(3,4)],[(2,5),(3,4),(4,3)],[(3,2),(4,2),(4,3)],[(3,4),(4,2),(4,3)]]
- ntr test = [[(1,2),(1,3),(2,1),(2,3),(3,2),(4,2),(2,5),(3,4),(4,3)],[(1,2),(2,1)]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement