string-copy - copy a string

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

SYNOPSIS

(string-copy string)
(string-copy string start)          ;R7RS
(string-copy string start end)      ;R7RS

DESCRIPTION

Returns a newly allocated copy of the part of the given string between start and end.

IMPLEMENTATION NOTES

Some implementations have a single empty string object which is returned if start = end, see make-string(3scm).

RETURN VALUES

Returns a single value which is a string.

EXAMPLES

(string-copy "foo")
        => "foo"

;; R7RS
(string-copy "Hello" 1)
        => "ello"

APPLICATION USAGE

This procedure makes sense in the presence of mutating string procedures like string-set!(3scm). It is commonly used to create copies of strings where there is an original copy of a string that should not be mutated by the receiver of the copy.

COMPATIBILITY

This procedure is missing in IEEE Scheme.

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

substring(3scm), string-copy!(3scm)

STANDARDS

R4RS, R5RS, R6RS, R7RS

HISTORY

The string-copy procedure first appeared in R2RS.

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.