[Haskell-cafe] using Map rather than FiniteMap

David Menendez zednenem at psualum.com
Tue Jan 25 22:59:48 EST 2005

S. Alexander Jacobson writes:

> After actually running the correct test, I am 
> still getting semi-ridiculous space behavior 
> (6k/pair)!
>     import qualified Map
>     zipped =zip [1..] [1..100000]::[(Int,Int)]
>     untup f (x,y) = f x y
>     produce = foldr (untup Map.insert) Map.empty zipped
>     fm = length  $ Map.keys produce
>     main = print $ fm

Two questions I'm currently too lazy to investigate myself:

Does having 'zipped' at the top level mean that the program is keeping
the entire 100,000-element list in memory?

Also, would performance improve if you used Map.fromList? How about
David Menendez <zednenem at psualum.com> | "In this house, we obey the laws
<http://www.eyrie.org/~zednenem>      |        of thermodynamics!"

More information about the Haskell-Cafe mailing list