Created
June 1, 2010 22:06
-
-
Save devn/421584 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 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