A few remarks:
>
> ## begin
> (defn f-to-seq[file]
> (with-open [rdr (java.io.BufferedReader.
> (java.io.FileReader. file))]
> (doall (line-seq rdr))))
>
Do you need the doall?
> (defn str-sort[str]
> (if (nil? str)
> str
> (String. (into-array (. Character TYPE) (sort str)))))
>
(and str
(String. (into-array (. Character TYPE) (sort str))))
(if str is nil this will return nil)
> (defn anagram-add[anagrams akey word]
> (if (empty? (get anagrams akey))
> (assoc anagrams akey (hash-map :count 1, :words (list word)))
> (update-in (update-in anagrams [akey :count] inc) [akey :words]
> conj word)))
>
You could use a literal {:count 1 :words (list words)} instead of hash-map
I believe that (get anagrams akey) will give nil in case there is known.
If it is the case (or (get anagrams key) ...) will be more readable.
(update-in ...) =>
(-> anagrams
(update-in [akey :count] inc)
(update-in [akey :words] conj word))
I will have a look to the rest of the program later.
Best,
Nicolas.
--
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