Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何定义函数,为第一个映射的每个键查找第二个映射的值,将一些函数应用于这两个值并生成第三个映射?
∷ (α → Maybe β → γ) → Map k α → Map k β → Map k γ
我玩了一些 , 和 的组合unionWith,differenceWith但intersectionWith坚持将它们与lookup.
unionWith
differenceWith
intersectionWith
lookup
是
foo :: (α → Maybe β → γ) → Map k α → Map k β → Map k γ foo comb ma mb = Map.mapWithKey (\k a -> comb a (Map.lookup k mb)) ma
你想要什么?