<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>54326</integer>
    </number>
    <user>
      <string>fax</string>
    </user>
    <title>
      <string>markov</string>
    </title>
    <contents>
      <string>(defun replacement (string index span with)
  (flet ((before (index) (subseq string 0 index))
         (after (index) (subseq string index)))
    (concatenate 'string
                 (before index)
                 with
                 (after (+ index span)))))

(defun markov (rules text)
  (let ((replacement
         (car (sort (remove-if #'null
                               (map 'list #'(lambda (rule)
                                              (list (search (first rule) text)
                                                    (length (first rule))
                                                    (second rule)))
                                    rules)
                               :key #'car)
                    #'&lt;
                    :key #'car))))
    (if replacement
        (markov rules (apply #'replacement text replacement))
        text)))

</string>
    </contents>
    <universal-time>
      <integer>3409494876</integer>
    </universal-time>
    <channel>
      <string>#lispcafe</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </paste>
</paste-with-annotations>