Code: Select all
(define (edits1 word)
(let ((l (length word)) (res '()))
(for (i 0 (- l 1)) (push (replace (nth i (string word)) (string word) "") res -1)) ; deletion
(for (i 0 (- l 2)) (push (swap i (+ i 1) (string word)) res -1)) ; transposition
(for (i 0 (- l 1)) (for (c (char "a") (char "z"))
(push (replace (nth i (string word)) (string word) (char c)) res -1) ; alteration
(push (replace (nth i (string word)) (string word) (string (char c) (nth i (string word)) )) res -1))) ; insertion
res))
Lutz said I was using 'string casts' - I think he meant those
Code: Select all
(string word)