;; Awesome. Implementation of a word trie in clojure.
(use '[clojure.string :only (split-lines)])

(def words (map seq (split-lines (slurp "words.txt"))))

(defn add-to-trie [trie x]
  (assoc-in trie x {:terminal true}))

(defn in-trie? [trie x]
  (get-in trie `(~@x :terminal)))

(def trie (reduce add-to-trie {} words))

(defn word-in-trie? [w] (in-trie? trie (seq w)))

Generated by jmatt using JMatt's version of scpaste at Wed Oct 5 21:12:16 2011. MST. (original)