Skip to content

Instantly share code, notes, and snippets.

@vicalejuri
Created August 9, 2010 05:18
Show Gist options
  • Select an option

  • Save vicalejuri/514976 to your computer and use it in GitHub Desktop.

Select an option

Save vicalejuri/514976 to your computer and use it in GitHub Desktop.

Revisions

  1. Frangossauro created this gist Aug 9, 2010.
    20 changes: 20 additions & 0 deletions gistfile1.sls
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    (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*)))))