[Haskell-beginners] Re: [Haskell-cafe] represent data sturcture
dave at zednenem.com
Mon Dec 29 13:26:12 EST 2008
On Mon, Dec 29, 2008 at 4:48 AM, Ryan Ingram <ryani.spam at gmail.com> wrote:
> On Sun, Dec 28, 2008 at 10:13 PM, David Menendez <dave at 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 <dave at zednenem.com>
More information about the Beginners