Skip to content

Instantly share code, notes, and snippets.

@biesnecker
Created January 20, 2012 09:38
Show Gist options
  • Save biesnecker/1646443 to your computer and use it in GitHub Desktop.
Save biesnecker/1646443 to your computer and use it in GitHub Desktop.
#77: Anagram Finder
;; by inecas (http://www.4clojure.com/user/inecas)
(fn [c]
(set (map set
(filter #(< 1 (count %))
(vals (group-by sort c))))))
(fn [wordlist]
(let [srtfunc (fn [x] (apply str (sort x)))]
(apply hash-set
(filter #(> (count %) 1)
(map #(apply hash-set %)
(vals (reduce #(assoc %1 (srtfunc %2)
(conj (%1 (srtfunc %2)) %2)) {} wordlist)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment