Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mergeIM :: (Int->a->Maybe b->c) -> IM.IntMap a -> IM.IntMap b -> IM.IntMap c
- mergeIM = case True of
- True -> mergeIM_s
- False -> mergeIM_f
- mergeIM_s :: (Int->a->Maybe b->c) -> IM.IntMap a -> IM.IntMap b -> IM.IntMap c
- mergeIM_s f im im' = IM.mapWithKey g im
- where
- g k x = f k x $ IM.lookup k im'
- mergeIM_f :: (Int->a->Maybe b->c) -> IM.IntMap a -> IM.IntMap b -> IM.IntMap c
- mergeIM_f f = IM.mergeWithKey mrg (IM.mapWithKey lft) (const IM.empty)
- where
- mrg i x y = Just $ f i x $ Just y
- lft i x = f i x Nothing
Add Comment
Please, Sign In to add comment