I'm attempting to write a simple histogram function:
<code>
(defn create-histogram [f]
(let
[words (read-lines f)
histo {}]
(doall
(map
(fn [w] (assoc histo w (+1 (get histo w 0))))
words))
histo))
(create-histogram "./testwords")
</code>
The input, 'f', is expected to be a file of words, as you'd get from
'/usr/share/dict/words'.
I don't see how to accumulate the results in the map, 'histo'. This is
really a question of how does one map a function to a collection and
accumulate the results...
-Todd
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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