Skip to content

Instantly share code, notes, and snippets.

@fstamour
Created July 11, 2014 18:29
Show Gist options
  • Save fstamour/d2617da7ec385007d643 to your computer and use it in GitHub Desktop.
Save fstamour/d2617da7ec385007d643 to your computer and use it in GitHub Desktop.
Reduce-strings Join adjacent strings in a list, leave other values intact.
;; 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