; (rm1 "abc" 0) ==> "bc" (rm1 "tea" 1) ==> "ta"
(defun rm1 (seq which)
(remove-if #'true seq :start which :end (1+ which)))
; (consword #\a "bc") ==> "abc"
(defun consword (char word)
(concatenate 'string (string char) word))
; (anagrams "ah") ==> ("ah" "ha")
(defun anagrams (word)
(if (= (length word) 1) (list word)
(loop as x across word
as i upfrom 0
as subword = (rm1 word i)
nconc (loop as y in (anagrams subword)
collect (consword x y)))))
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 56:25:54 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,806 |