Skip to content

Instantly share code, notes, and snippets.

Created July 20, 2014 14:24
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 anonymous/595f08e9b6612d1b5405 to your computer and use it in GitHub Desktop.
Save anonymous/595f08e9b6612d1b5405 to your computer and use it in GitHub Desktop.
(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