Advertisement
ovitus

Untitled

Nov 8th, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. ntr :: Eq a => [[a]] -> [[a]]
  2. ntr = foldr (\x acc -> ntr' x acc) []
  3. ntr' x [] = [x]
  4. ntr' x (y:ys) = case x `intersect` y of
  5. [] -> y : ntr' x ys
  6. _ -> (x `union` y) : ys
  7.  
  8. 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)]]
  9.  
  10. 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