Created
July 11, 2014 18:29
-
-
Save fstamour/d2617da7ec385007d643 to your computer and use it in GitHub Desktop.
Reduce-strings Join adjacent strings in a list, leave other values intact.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Took from postmodern's s-sql.lisp | |
(defun reduce-strings (list) | |
"Join adjacent strings in a list, leave other values intact." | |
(let ((accum ()) | |
(span "")) | |
(dolist (part list) | |
(cond ((stringp part) (setf span (concatenate 'string span part))) | |
(t (when (not (string= "" span)) | |
(push span accum) | |
(setf span "")) | |
(push part accum)))) | |
(if (not (string= "" span)) | |
(push span accum)) | |
(nreverse accum))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment