Created
July 20, 2014 15:18
-
-
Save anonymous/5233a7e836f15be227a5 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 []] | |
(if (= (count words) 5) | |
words | |
(if (empty? words) | |
(let [[word next-words] (rand-nth (seq chain)) | |
next-word (rand-nth next-words)] | |
(recur (conj words word next-word))) | |
(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