mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
fixing portable string-join definition to allow a separator
This commit is contained in:
parent
ca1a2bd3ae
commit
7b0cca9403
1 changed files with 11 additions and 1 deletions
|
@ -61,7 +61,17 @@
|
||||||
(define (string-cursor-prev s i) (- i 1))
|
(define (string-cursor-prev s i) (- i 1))
|
||||||
(define (substring-cursor s start . o)
|
(define (substring-cursor s start . o)
|
||||||
(substring s start (if (pair? o) (car o) (string-length s))))
|
(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 string-size string-length)
|
||||||
(define (call-with-output-string proc)
|
(define (call-with-output-string proc)
|
||||||
(let ((out (open-output-string)))
|
(let ((out (open-output-string)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue