Bohtvaroh

Blogger - HTIF - intersection

Oct 4th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- |Finds lists intersection. O(2nlogn + 2n)
  2. intersection :: Ord a => [a] -> [a] -> [a]
  3. intersection = iter intersectF
  4.  
  5. intersectF :: Eq a => (Maybe a, Maybe a) -> [a] -> [a]
  6. intersectF (Just x, Just y) acc = if x == y then x:acc else acc
  7. intersectF _ acc = acc
Advertisement
Add Comment
Please, Sign In to add comment