Skip to content

Instantly share code, notes, and snippets.

@devn
Created June 1, 2010 22:06
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 devn/421584 to your computer and use it in GitHub Desktop.
Save devn/421584 to your computer and use it in GitHub Desktop.
(defn markov-chain [index key]
"Lazily creates a markov chain"
(let [completion (markov-next index key)
next-key (nthrest (concat key completion) (count completion))]
(if (nil? completion)
'()
(lazy-cons (first completion) (markov-chain index next-key)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment