| Paste number 54326: | markov |
| Pasted by: | fax |
| 6 months, 1 week ago | |
| #lispcafe | Context in IRC logs | |
| Paste contents: |
| (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) #'< :key #'car)))) (if replacement (markov rules (apply #'replacement text replacement)) text))) |
This paste has no annotations.