Created
July 20, 2014 14:24
-
-
Save anonymous/595f08e9b6612d1b5405 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
(defn build-words [chain] | |
(loop [words []] | |
(cond | |
(empty? words) | |
(let [[word next-words] (rand-nth (seq chain)) | |
next-word (rand-nth (seq next-words))] | |
(recur (conj words word next-word))) | |
(not (empty? words)) | |
(let [last-word (last words) | |
next-words (get chain last-word)] | |
(if (nil? next-words) | |
words | |
(recur (conj words (rand-nth (seq next-words))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment