On Mon, Dec 29, 2008 at 4:48 AM, Ryan Ingram <ryani.s...@gmail.com> wrote: > On Sun, Dec 28, 2008 at 10:13 PM, David Menendez <d...@zednenem.com> 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 <d...@zednenem.com> <http://www.eyrie.org/~zednenem/> _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe