Soundex: Difference between revisions
Content deleted Content added
→{{header|Common Lisp}}: Forgot reverse. |
→{{header|Common Lisp}}: Graceful behavior on empty string. |
||
Line 212: | Line 212: | ||
(defun soundex (s) |
(defun soundex (s) |
||
( |
(if (zerop (length s)) |
||
"" |
|||
(o (list (first l)))) |
|||
( |
(let* ((l (coerce (string-upcase s) 'list)) |
||
(o (list (first l)))) |
|||
(loop for c in (rest l) |
|||
for cg = (get-code c) and |
|||
for cp = #\Z then cg |
|||
when (and cg (not (eql cg cp))) do |
|||
(push (get-code c) o) |
|||
finally |
|||
(return (subseq (coerce (nreverse `(#\0 #\0 #\0 #\0 ,@o)) 'string) 0 4)))))) |
|||
</lang> |
</lang> |
||