Strings are sequences of characters.
Strings are written as sequences of characters enclosed within doublequotes
("
). A doublequote can be written inside a string only by escaping
it with a backslash (\), as in
"The word \"recursion\" has many meanings."
A backslash can be written inside a string only by escaping it with another backslash. Scheme does not specify the effect of a backslash within a string that is not followed by a doublequote or backslash.
A string constant may continue from one line to the next, but the exact contents of such a string are unspecified.
The length of a string is the number of characters that it contains. This number is an exact, non-negative integer that is fixed when the string is created. The valid indexes of a string are the exact non-negative integers less than the length of the string. The first character of a string has index 0, the second has index 1, and so on.
In phrases such as "the characters of string beginning with index start and ending with index end," it is understood that the index start is inclusive and the index end is exclusive. Thus if start and end are the same index, a null substring is referred to, and if start is zero and end is the length of string, then the entire string is referred to.
Some of the procedures that operate on strings ignore the
difference between upper and lower case. The versions that ignore case
have "-ci
" (for "case insensitive") embedded in their
names.
string? obj | procedure |
Returns #t if obj is a string, otherwise returns #f. |
make-string k | procedure |
make-string k char | procedure |
|
string char ... | library procedure |
Returns a newly allocated string composed of the arguments. |
string-length string | procedure |
Returns the number of characters in the given string. |
string-ref string k | procedure |
k must be a valid index of string.
|
string-set! string k char | procedure |
k must be a valid index of string
.
(define (f) (make-string 3 #\*)) (define (g) "***") (string-set! (f) 0 #\?) ==> unspecified (string-set! (g) 0 #\?) ==> error (string-set! (symbol->string 'immutable) 0 #\?) ==> error |
string=? string1 string2 | library procedure |
string-ci=? string1 string2 | library procedure |
Returns #t if the two strings are the same length and contain the same
characters in the same positions, otherwise returns #f.
|
string<? string1 string2 | library procedure |
string>? string1 string2 | library procedure |
string<=? string1 string2 | library procedure |
string>=? string1 string2 | library procedure |
string-ci<? string1 string2 | library procedure |
string-ci>? string1 string2 | library procedure |
string-ci<=? string1 string2 | library procedure |
string-ci>=? string1 string2 | library procedure |
These procedures are the lexicographic extensions to strings of the
corresponding orderings on characters. For example, Implementations may generalize these and the |
substring string start end | library procedure |
String must be a string, and start and end must be exact integers satisfying 0 <= start <= end <= (string-length string).
Substring returns a newly allocated string formed from the characters of
string beginning with index start (inclusive) and ending with index
end (exclusive).
|
string-append string ... | library procedure |
Returns a newly allocated string whose characters form the concatenation of the given strings. |
string->list string | library procedure |
list->string list | library procedure |
|
string-copy string | library procedure |
Returns a newly allocated copy of the given string. |
string-fill! string char | library procedure |
Stores char in every element of the given string and returns an unspecified value. |