;;;; ;;;; Standard strings in Scheme are immutable. There seems to be one ;;;; relatively easy ways around this problem: ;;;; ;;;; 1) Use what C++ would call an ostringstream: ;;;; ;;;; (define s (open-output-string)) ;;;; (display "Hello, World!" s) ;;;; (newline s) ;;;; (display "Goodbye, Cruel World!" s) ;;;; (newline s) ;;;; (get-ouput-string s) ;;;; ;;;; Also see the dstring2.scm file for an equivalent class that is ;;;; implemented using lists of characters instead. ;;;; ;;;; WARNING: This implementation depends on open-output-string which ;;;; is not standard, but is available in at least chicken, guile, and ;;;; mzscheme. If your scheme interpreter does not support ;;;; open-output-string, use the implementation in dstring2.scm which ;;;; is based on lists and should be portable to any scheme ;;;; interpreter. ;;;; (define (dstring) (open-output-string)) (define (dstring->string s) (get-output-string s)) (define (dstring->list s) (string->list (dstring->string s))) (define (dstring-append s x) (display x s)) (define (dstring-append-char s c) (display c s)) (define (dstring-append-line s . args) (if (not (null? args)) (display (car args) s)) (newline s)) ;;(define (dstring-clear s) ;; (file-position s 0))