Last active
August 29, 2015 13:57
-
-
Save shepmaster/9590585 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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