Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > 6b3585ea67ce3e79c9049b5b33294cdd > files > 694

docbook-style-dsssl-doc-1.79-16.mga7.noarch.rpm

<RefEntry id="string-replace">
<!-- This file is generated automatically from the DSSSL source. -->
<!-- Do not edit this file! -->
<?html-filename string-replace.html>

<RefMeta>
  <RefEntryTitle>string-replace</RefEntryTitle>
  <RefMiscInfo Role="file">dblib.dsl</RefMiscInfo>
</RefMeta>

<RefNameDiv>
  <RefName>string-replace</RefName>
  <RefPurpose>Replace all occurances of a target substring in a string</RefPurpose>
</RefNameDiv>

<RefSynopsisDiv><Title>Synopsis</Title>
<Synopsis>
(string-replace string target repl)
</Synopsis>
</RefSynopsisDiv>

<RefSect1><Title>Description</Title>

<para>
Replaces all occurances of <literal>target</literal> in <literal>string</literal> with <literal>repl</literal>.</para>


</RefSect1>

<RefSect1><Title>Author</Title>

<para>
Norman Walsh, &lt;ndw@nwalsh.com&gt;
</para>
</RefSect1>
<RefSect1><Title>Source Code</Title>

<ProgramListing>
(define (string-replace string target repl)
  ;; Replace all occurances of a target substring in a string
  (let loop ((str string) (pos 0))
    (if (>= pos (string-length str))
	str
	(loop (repl-substring str target repl pos) 
	      (if (repl-substring? str target pos)
		  (+ (string-length repl) pos)
		  (+ 1 pos))))))
</ProgramListing>
</RefSect1>

</RefEntry>