string-copy!(3scm) Scheme Programmer's Manual string-copy!(3scm)

string-copy! - copy from a string into another string

(import (scheme base))              ;R7RS

(string-copy! to at from)
(string-copy! to at from start)
(string-copy! to at from start end)

Copies the characters of the string from between start and end to the string to, starting at at.

The order in which characters are copied is unspecified, except that if the source and destination overlap, copying takes place as if the source is first copied into a temporary string and then into the destination. This can be achieved without allocating storage by making sure to copy in the correct direction in such circumstances.

Returns an unspecified value.

(define a "12345")
(define b (string-copy "abcde"))
(string-copy! b 1 a 0 2)
b  =>  "a12de"

This procedure is unique to R7RS.

It is an error if at is less than zero or greater than the length of to. It is also an error if (- (string-length to) at) is less than (- end start). It is also an error if the wrong number arguments was passed or an argument was outside its domain. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

string-set!(3scm)

R7RS

This procedure first appeared in R7RS. In R2RS there were the procedures substring-move-right! and substring-move-left! that had the same effect.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2022-05-14