Re: Newbie question on the use of functional hash maps

2008-10-20 Thread Parth Malwankar
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

Re: Newbie question on the use of functional hash maps

2008-10-19 Thread wwmorgan
If you're interested only in counting the number of unique words, then you don't even need a map. You can get by with a set, like this: (defn unique-words-in-file [file] (count (set (split-on-whitespace (slurp file) slurp reads file into a String object in memory. The hypothetical spli

Newbie question on the use of functional hash maps

2008-10-19 Thread Tom Emerson
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