(letrec* ((*tree* '(#\t #\r #\e #\e #\o #\n #\e)) (*forest* '(#\f #\o #\r #\e #\s #\t)) (rep (lambda (t r) (let ((c (read-char))) (cond ((eof-object? c) r) ((char=? c (car t)) (if (length=? t 1) (append *forest* (rep *tree* '())) (rep (cdr t) (append r (list c))))) (else (append r (list c) (rep *tree* '())))))))) (begin (for-each display (rep *tree* '())) (newline)))