From 7b0cca9403b1f3a6b24ced1b4382b46d1aad57c6 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 28 Sep 2016 23:22:44 +0900 Subject: [PATCH] fixing portable string-join definition to allow a separator --- lib/chibi/string.sld | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/chibi/string.sld b/lib/chibi/string.sld index 4c13ab28..dc717165 100644 --- a/lib/chibi/string.sld +++ b/lib/chibi/string.sld @@ -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)))