This commit is contained in:
paku 2024-10-03 10:28:59 +09:00
parent 8c539dc879
commit bc2bc378c7

View file

@ -46,15 +46,16 @@
(defun minify (input-string)
(with-output-to-string (out)
(let ((previous-space-p nil))
(loop for char across input-string do
(cond
((whitespace-p char)
(unless previous-space-p
(write-char #\Space out))
(setf previous-space-p t))
(t
(write-char char out)
(setf previous-space-p nil)))))))
(loop
:for char :across input-string
:do (cond
((whitespace-p char)
(unless previous-space-p
(write-char #\Space out))
(setf previous-space-p t))
(t
(write-char char out)
(setf previous-space-p nil)))))))
(defun whitespace-p (char)
(member char '(#\Space #\Newline #\Tab #\Return) :test #'char=))