Skip to content

Commit

Permalink
printing lists with a delimiter
Browse files Browse the repository at this point in the history
> (print-list-delimited '(1 asd "foo"))
1,ASD,"foo"
  • Loading branch information
Student committed Jun 29, 2015
1 parent ad6191f commit 272ec0b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions strings.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@
(setf acc nil)
else do (push char acc)
finally (return (nreverse (cons (coerce (nreverse acc) 'string) rtn)))))

(defun print-list-delimited (list &optional (stream *standard-output*) (printer #'prin1) (delimiter ","))
"Output LIST to STREAM as a comma separated listing."
(loop for els on list
do (funcall printer (car els) stream)
(unless (null (cdr els))
(princ delimiter stream))))

0 comments on commit 272ec0b

Please sign in to comment.