我想從一個Data.Map
匹配特定的條件下,其刪除所有元素。說foobar
是這個功能,這是他需要的行爲:如何從Haskell Map中刪除所有與它們的值不匹配的條件匹配的元素?
foobar :: (a -> Bool) -> Map k a -> Map k a
foobar (>= 20) $ fromList [("john",3),("sasha",8),("mary",33),("philip",20)]
-- the expected result is fromList [("john",3),("sasha",8)]
感謝您的任何答覆!