Next: , Previous: List/String Conversion, Up: Strings


21.4.5 String Selection

Portions of strings can be extracted by these procedures. string-ref delivers individual characters whereas substring can be used to extract substrings from longer strings.

— Scheme Procedure: string-length string
— C Function: scm_string_length (string)

Return the number of characters in string.

— Scheme Procedure: string-ref str k
— C Function: scm_string_ref (str, k)

Return character k of str using zero-origin indexing. k must be a valid index of str.

— Scheme Procedure: string-copy str [start [end]]
— C Function: scm_string_copy (str, start, end) |1 |2 |0

Return a freshly allocated copy of the string str.

— Scheme Procedure: substring str start [end]
— C Function: scm_substring (str, start, end) |2 |1 |0

Return a newly allocated string formed from the characters of string str beginning with index start (inclusive) and ending with index end (exclusive).

Both start and end may be a negative number n, in which case they refer to the index −n counted from the end of the string.