Node:SRFI-13 Replicate/Rotate, Next:, Previous:SRFI-13 Fold/Unfold/Map, Up:SRFI-13

39.11.13 Replicate/Rotate

These procedures are special substring procedures, which can also be used for replicating strings. They are a bit tricky to use, but consider this code fragment, which replicates the input string "foo" so often that the resulting string has a length of six.

(xsubstring "foo" 0 6)

xsubstring s from [to start end] Scheme Procedure
This is the extended substring procedure that implements replicated copying of a substring of some string.

s is a string, start and end are optional arguments that demarcate a substring of s, defaulting to 0 and the length of s. Replicate this substring up and down index space, in both the positive and negative directions. xsubstring returns the substring of this string beginning at index from, and ending at to, which defaults to from + (end - start).

string-xcopy! target tstart s sfrom [sto start end] Scheme Procedure
Exactly the same as xsubstring, but the extracted text is written into the string target starting at index tstart. The operation is not defined if (eq? target s) or these arguments share storage - you cannot copy a string on top of itself.