On Oct 20, 6:16 am, "Tom Emerson" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a somewhat embarassing newbie question on the use of hash maps
> in a functional environment.
>
> Consider a little utility that counts the number of unique words in a
> file. A hash map mapping strings to integers is the obvious data
> structure for this, but the fact that (assoc) returns a new map each
> time it is called is tripping me up: since I can't define a 'global'
> hash map to accumulate the counts, do you pass one around in a
> function? or do you structure the code a different way? This is a
> difference from what I would do in Common Lisp, where I would just
> have a global that is used for the collection.

The word count program already mentioned in this thread is
nice.

If you do need to maintain state, this thread has some pointers:
http://groups.google.com/group/clojure/browse_thread/thread/a60b20955ad47fca

Parth

>
> Thanks in advance for your wisdom.
>
>     -tree
>
> --
> Tom Emerson
> [EMAIL PROTECTED]://www.dreamersrealm.net/~tree
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to