I think I mostly avoided using macros until now, but here's something I tried and it doesn't look good to me, particularly the '(,@whites) part - that shouldn't need so much of ASCII art, must be a better way to handle it!
- Code: Select all
((word start end
&aux (whites '(#\Space #\Tab #\Newline #\Rubout)))
`(do ((,end 0 (1+ ,end))
((= ,end (1+ (length ,s))))
(if (or (= ,end (length ,s)) (find (aref ,s ,end) '(,@whites)))
(if (> len 0)
(setf ,word (subseq ,s ,start ,end))
(setf len 0 ,start (1+ ,end)))
(with-words-in-string (word start end)
"Quick brown fox jumped over the lazy dog"
(format t "word: ~s, start: ~s, end: ~s~&" word start end))