While speaking of buffers, is there an efficient, low-level way to set
a substring within an existing string? Like this but faster:
(define (substring-set! buffer replace start #!optional (count #f))
(let ((buffer-size (string-length buffer))
(replace-len (string-length replace)))
(let loop ((current 0))
(let ((buffer-pos (+ current start)))
(when (and (< current replace-len)
(< buffer-pos buffer-size)
(if count (< current count) #t))
(string-set! buffer buffer-pos (string-ref replace current))
(loop (add1 current)))))))
;;; example
;;; #;1> (define s (make-string 10))
;;; #;2> (substring-set! s "hello" 3 4 )
;;; #;3> s
;;; " hell "
Thanks,
Graham
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users