Skip to content

Instantly share code, notes, and snippets.

@vicalejuri
Created August 9, 2010 05:18
Show Gist options
  • Save vicalejuri/514976 to your computer and use it in GitHub Desktop.
Save vicalejuri/514976 to your computer and use it in GitHub Desktop.
(define 2ndorder-markov
(lambda (:phrase)
(if (= (length :phrase) 1) (list (first :phrase))
(list (second :phrase)))))
(define 3ndorder-markov
(lambda (:phrase)
(cond
((= (length :phrase) 1) (list (first :phrase)))
((= (length :phrase) 2) (list (second :phrase)))
(else
(list (second :phrase) (third :phrase))))))
; Given an phrase and an markov-order function, return a newly trained brain
(define teach-phrase
(lambda (:phrase :brain *orderfn*)
(cond ((null? :phrase) :brain)
(else
(teach-phrase (cdr :phrase)
(alist-cons (first :phrase) (*orderfn* :phrase) :brain) *orderfn*)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment