
Hi all, As I tried to convert some of my code to newer libraries comming with GHC 6.4, I would like to share two things with you: I noticed that there are two functions missing: deleteList and insertList. The first one is easy with foldl: deleteList list map = foldl (flip Data.Map.delete) map list Second one is even shorter: insertList asclist map = union map (Data.Map.fromList asclist) Still I find both of them useful also execution speed seems to be of some concern here. Why generate temporary map just to join it with second in a moment? Isn't it slower? Also why Data.Map.lookup and Data.Map.findWithDefault? Why not lookupWithDefault? Besides, I really like new library :) -- Gracjan

Sebastian Sylvan wrote:
On Apr 3, 2005 9:38 AM, Gracjan Polak
wrote: insertList asclist map = union map (Data.Map.fromList asclist)
How about:
insertList :: (Ord a) => Map a b -> [(a, b)] -> Map a b insertList = foldr (uncurry insert)
Is there any reason why foldr is better than foldl here?
/S
-- Gracjan
participants (2)
-
Gracjan Polak
-
Sebastian Sylvan