Next: String Comparison, Previous: String Selection, Up: Strings
These procedures are for modifying strings in-place. This means that the result of the operation is not a new string; instead, the original string's memory representation is modified.
Store CHR in element K of STRING and returns an unspecified value. K must be a valid index of STR.
Store chr in every element of the given str. The return value is unspecified.
Change every character in str between start and end to fill char.
(define y "abcdefg") (substring-fill! y 1 3 #\r) y ⇒ "arrdefg"
Copy the substring of str1 bounded by start1 and end1 into str2 beginning at position end2.
substring-move-right!begins copying from the rightmost character and moves left, andsubstring-move-left!copies from the leftmost character moving right.It is useful to have two functions that copy in different directions so that substrings can be copied back and forth within a single string. If you wish to copy text from the left-hand side of a string to the right-hand side of the same string, and the source and destination overlap, you must be careful to copy the rightmost characters of the text first, to avoid clobbering your data. Hence, when str1 and str2 are the same string, you should use
substring-move-right!when moving text from left to right, andsubstring-move-left!otherwise. Ifstr1and ‘str2’ are different strings, it does not matter which function you use.