Bohtvaroh

Blogger - HTIF - subtraction

Oct 4th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- |Subtracts second list from the first. O(2nlogn + 2n)
  2. subtraction :: Ord a => [a] -> [a] -> [a]
  3. subtraction = iter subtractF
  4.  
  5. subtractF :: Eq a => (Maybe a, Maybe a) -> [a] -> [a]
  6. subtractF (Just x, Just y) acc = if x /= y then x:acc else acc
  7. subtractF (Just x, Nothing) acc = x:acc
  8. subtractF _ acc = acc
Advertisement
Add Comment
Please, Sign In to add comment