Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Strings   [Contents][Index]


6.6.5.6 String Modification

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.

Scheme Procedure: string-set! str k chr
C Function: scm_string_set_x (str, k, chr)

Store chr in element k of str and return an unspecified value. k must be a valid index of str.

C Function: void scm_c_string_set_x (SCM str, size_t k, SCM chr)

Like scm_string_set_x, but the index is given as a size_t.

Scheme Procedure: string-fill! str chr [start [end]]
C Function: scm_substring_fill_x (str, chr, start, end)
C Function: scm_string_fill_x (str, chr)

Stores chr in every element of the given str and returns an unspecified value.

Scheme Procedure: substring-fill! str start end fill
C Function: scm_substring_fill_x (str, start, end, fill)

Change every character in str between start and end to fill.

(define y (string-copy "abcdefg"))
(substring-fill! y 1 3 #\r)
y
⇒ "arrdefg"
Scheme Procedure: substring-move! str1 start1 end1 str2 start2
C Function: scm_substring_move_x (str1, start1, end1, str2, start2)

Copy the substring of str1 bounded by start1 and end1 into str2 beginning at position start2. str1 and str2 can be the same string.

Scheme Procedure: string-copy! target tstart s [start [end]]
C Function: scm_string_copy_x (target, tstart, s, start, end)

Copy the sequence of characters from index range [start, end) in string s to string target, beginning at index tstart. The characters are copied left-to-right or right-to-left as needed – the copy is guaranteed to work, even if target and s are the same string. It is an error if the copy operation runs off the end of the target string.


Next: , Previous: , Up: Strings   [Contents][Index]