
29 Dec
2008
29 Dec
'08
1:26 p.m.
On Mon, Dec 29, 2008 at 4:48 AM, Ryan Ingram
On Sun, Dec 28, 2008 at 10:13 PM, David Menendez
wrote: Here's the simplest way:
update k v map = \k' -> if k' == k then v else map k'
Of course this version of update leaks crazy amounts of memory:
let bigmap = iterate (update Male 150) classA !! 100000 bigmap Male
"bigmap" leaves a huge chain of thunks pointing at each other, which can never be freed.
Sure. It's slow, too. If you want a map that you can update, you're
usually much better off with a concrete data structure.
--
Dave Menendez