string-fill! - fill a string with a character

LIBRARY

(import (rnrs mutable-strings))     ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

SYNOPSIS

(string-fill! string char)
(string-fill! string char start)      ;R7RS
(string-fill! string char start end)  ;R7RS

DESCRIPTION

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.

RETURN VALUES

R6RS
Returns unspecified values.
R7RS
Returns an unspecified value.

EXAMPLES

;; R7RS example
(let ((s (make-string 4 #\x)))
  (string-fill! s #\y 2)
  s)  =>  "xxyy"

APPLICATION USAGE

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.

COMPATIBILITY

The start and end arguments are unique to R7RS.

ERRORS

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.

SEE ALSO

make-string(3scm), string-set!(3scm)

STANDARDS

R4RS, R5RS, R6RS, R7RS

HISTORY

The first Scheme report to carry this procedure was R2RS, which also had substring-fill! that filled a substring, but used a different argment order: (substring-fill! string start end char). It is missing from IEEE Scheme.

AUTHORS

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


Markup created by unroff 1.0sc,    March 04, 2023.