string-set! - modify a string element
(import (rnrs mutable-strings)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(string-set! string k char)
Implementors should make
run in constant time, which may mean that this procedure will also run
in constant time.
There is no requirement for this procedure to execute in constant
Returns unspecified values.
Returns an unspecified value.
(define (f) (make-string 3 #\*))
(define (g) "***")
(string-set! (f) 0 #\?) => unspecified
(string-set! (g) 0 #\?) => unspecified
; should raise &assertion exception
This procedure is rarely used to modify existing strings. It is
sometimes used to build up new strings, but a better option is often
to use an output string created by
which have the benefit that the output length does not need to be
known in advance.
This procedure works the same everywhere. Whether a string literal is
truly immutable depends on the implementation (but they should not be
mutated either way).
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
must be a valid index of
which in turn must be a mutable string.
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
The first Scheme report to include this procedure was R2RS.
In R6RS this procedure was moved to its own library which is normally
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
Markup created by unroff 1.0sc, March 04, 2023.