fixing portable string-join definition to allow a separator

This commit is contained in:
Alex Shinn 2016-09-28 23:22:44 +09:00
parent ca1a2bd3ae
commit 7b0cca9403

View file

@ -61,7 +61,17 @@
(define (string-cursor-prev s i) (- i 1))
(define (substring-cursor s start . o)
(substring s start (if (pair? o) (car o) (string-length s))))
(define (string-concatenate ls) (apply string-append ls))
(define (string-concatenate orig-ls . o)
(let ((sep (if (pair? o) (car o) ""))
(out (open-output-string)))
(let lp ((ls orig-ls))
(cond
((pair? ls)
(if (and sep (not (eq? ls orig-ls)))
(write-string sep out))
(write-string (car ls) out)
(lp (cdr ls)))))
(get-output-string out)))
(define string-size string-length)
(define (call-with-output-string proc)
(let ((out (open-output-string)))