Adam Warner wrote:
Hi Lowell Kirsh,
I want to write a function to take a list of strings and a delimiter and return a string with the strings put together with the delimiter as glue.
e.g. (join '("foo" "bar" "baz")) -> "foo:bar:baz"
(defun join (list &optional (delimiter #\:))
(let ((countdown (length list)))
(with-output-to-string (stream)
(dolist (item list)
(write-string item stream)
(decf countdown)
(unless (zerop countdown)
(write-char delimiter stream))))))
Gauche Scheme
(define (join lst :optional (delimiter #\,))
(with-output-to-string
(lambda()
(display (car lst))
(for-each
(cut format #t "~a~a" delimiter <>)
(cdr lst)))))
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)