www.delorie.com/gnu/docs/guile/guile_474.html   search  
Buy GNU books!

Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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)

Scheme Procedure: xsubstring s from [to start end]
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).

Scheme Procedure: string-xcopy! target tstart s sfrom [sto start end]
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.

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003