substring - copy part of a string

LIBRARY

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

SYNOPSIS

(substring string start end)

DESCRIPTION

The substring procedure returns a newly allocated string formed from the characters of string beginning with index start (inclusive) and ending with index end (exclusive).

string must be a string, and start and end must be exact integer objects satisfying 0 ≤ startend(string-length string).

If start = end then the resulting empty string does not need to be newly allocated, as per eq?(3scm).

IMPLEMENTATION NOTES

Chez Scheme, Loko Scheme, (more?)
There is a unique empty string object.

RETURN VALUES

Returns a single string object.

EXAMPLES

(substring "SCHEMER" 0 6)  =>  "SCHEME"

COMPATIBILITY

This procedure is the same in all RnRS Scheme revisions since R2RS.

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

string-copy(3scm)

STANDARDS

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

HISTORY

This procedure was introduced in R2RS. Earlier revisions of Scheme ran on MacLisp, which had a substr function that it in turn copied from PL/I. Instead of the end argument, it had an optional length argument.

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.