string-fill! - fill a string with a character
(import (rnrs mutable-strings)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(string-fill! string char)
(string-fill! string char start) ;R7RS
(string-fill! string char start end) ;R7RS
Stores char in every element of string.
- R7RS
- Only modifies string between start (inclusive) and
end (exclusive). If omitted, start defaults to 0 and
end defaults to the length of string.
- R6RS
- Returns unspecified values.
- R7RS
- Returns an unspecified value.
;; R7RS example
(let ((s (make-string 4 #\x)))
(string-fill! s #\y 2)
s) => "xxyy"
This procedure is used to fill strings that have already been created. It has
marginal utility. The second argument to make-string(3scm) fills the
entire string at creation time.
The start and end arguments are unique to R7RS.
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.
- R7RS
- 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.
- Unsupported characters (R7RS)
- It is an error to fill with a character which the implementation does not
support. 7-bit ASCII (except #\null) must be supported. Any other
character is optional and potentially an error (as described above). You
can use the full-unicode feature identifier in
cond-expand(3scm) to check if all of Unicode 6.0 is supported.
The first Scheme report to carry this procedure was R2RS, which also had
substring-fill! that filled a substring, but used a different argument
order: (substring-fill! string start
end char). It is missing from IEEE Scheme.