Skip to content

Instantly share code, notes, and snippets.

@shepmaster
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shepmaster/9590585 to your computer and use it in GitHub Desktop.
Save shepmaster/9590585 to your computer and use it in GitHub Desktop.
(ns reemvoweler.sync)
(defn build-sentence [orig-tree tree words chars consonants vowels]
(lazy-seq
(if tree
(concat
(if-let [[c & consonants] (seq consonants)]
(build-sentence orig-tree (get tree c) words (conj chars c) consonants vowels))
(if-let [[v & vowels] (seq vowels)]
(build-sentence orig-tree (get tree v) words (conj chars v) consonants vowels))
(if (:word tree)
(let [word (apply str chars)
words (conj words word)]
(if (every? empty? [consonants vowels])
[words]
(build-sentence orig-tree orig-tree words [] consonants vowels))))))))
(defn all-results [tree consonants vowels]
(map (partial clojure.string/join " ")
(build-sentence tree tree [] [] consonants vowels)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment