Navigation Menu

Skip to content

Commit

Permalink
string-join can add separators at beginning and end now
Browse files Browse the repository at this point in the history
  • Loading branch information
OlafMerkert committed Mar 23, 2015
1 parent 621f642 commit a2d4be1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions strings.lisp
Expand Up @@ -14,12 +14,14 @@ replacement."
(princ (subseq string pos) str))))
(repl 0)))))

(defun string-join (sequence &optional (separator " "))
(defun string-join (sequence &optional (separator " ") start end)
"Concatenate the string representation of the elements of
`sequence', with `separator' between consecutive elements."
`sequence', with `separator' between consecutive elements. If `start'
or `end' is non-nil, put the separator also there."
(with-output-to-string (stream)
(le1 (first t)
(le1 (first (not start))
(map nil (lambda (x)
(if first (setf first nil) (princ separator stream))
(princ x stream))
sequence))))
sequence))
(when end (princ separator stream))))

0 comments on commit a2d4be1

Please sign in to comment.