[plt-scheme] help on how to write a frequency-counting function in a more functional way

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun May 3 14:51:45 EDT 2009

At Fri, 1 May 2009 22:35:37 -0400, Doug Orleans wrote:
> On Wed, Apr 29, 2009 at 5:53 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > With our implementation, immutable hash tables are probably only better
> > when they give you a better algorithm --- one that can needs O(1)
> > operations on a mapping and where the operations are aren't
> > "single-threaded" in the cumulative sense (i.e., you start with some
> > mapping and you want to extend it in different, independent ways).
> 
> By the way, is for/hash implemented using a mutable hash table during
> the loop? 

No.

> Or is the constant factor slowdown not high enough to
> bother?

Since the result is supposed to be an immutable table, I don't think
that building an intermediate mutable one would help. The immutable one
would still have to be built in the end.

Also, modifying a mutable hash table would interact badly with
continuations captured during the iteration.



Posted on the users mailing list.