Hello,
> (defn count-words [words]
> "Counts the occurrences of all words in the given string. Returns a
> map with the words as keys, their frequency as values"
> (loop [my-words (re-seq #"[a-zA-ZöäüÖÄÜß]+" words) word-map {}]
> (if (empty? my-words)
> word-map
> (recur (rest my-words) (merge-with + word-map {(first my-words)
> 1})))))
You can also use "frequencies" from c.c.seq-utils (http://
richhickey.github.com/clojure-contrib/seq-api.html#clojure.contrib.seq/
frequencies)
HTH,
--
Miki
--
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
To unsubscribe from this group, send email to
clojure+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.