1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
<RefEntry id="repl-substring-listX3F">
<!-- This file is generated automatically from the DSSSL source. -->
<!-- Do not edit this file! -->
<?html-filename repl-substring-list-p.html>
<RefMeta>
<RefEntryTitle>repl-substring-list?</RefEntryTitle>
<RefMiscInfo Role="file">dblib.dsl</RefMiscInfo>
</RefMeta>
<RefNameDiv>
<RefName>repl-substring-list?</RefName>
<RefPurpose>Perform repl-substring? with a list of target/replacement pairs</RefPurpose>
</RefNameDiv>
<RefSynopsisDiv><Title>Synopsis</Title>
<Synopsis>
(repl-substring-list? string replace-list pos)
</Synopsis>
</RefSynopsisDiv>
<RefSect1><Title>Description</Title>
<para>
Returns <literal>#t</literal> if any target in <literal>replace-list</literal> occurs at <literal>pos</literal> in <literal>string</literal>.
</para>
<variablelist>
<varlistentry><term><literal>string</literal></term>
<listitem>
<para>
The string in which replacement should be tested.
</para>
</listitem>
</varlistentry>
<varlistentry><term><literal>replace-list</literal></term>
<listitem>
<para>
A list of target/replacement pairs. This list is just a list of
strings, treated as pairs. For example, <literal>("was" "x" "is" "y")</literal>.
In this example, <literal>was</literal> may be replaced by <literal>x</literal> and <literal>is</literal> may be
replaced by <literal>y</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry><term><literal>pos</literal></term>
<listitem>
<para>
The location within <literal>string</literal> where the test will occur.
</para>
</listitem>
</varlistentry>
</variablelist>
</RefSect1>
<RefSect1><Title>Example</Title>
<para>
<literal>(repl-substring-list? "this is it" ("was" "x" "is" "y") 2)</literal>
returns <literal>#t</literal>: "is" could be replaced by "y".
</para>
</RefSect1>
<RefSect1><Title>Author</Title>
<para>
Norman Walsh, <ndw@nwalsh.com>
</para>
</RefSect1>
<RefSect1><Title>Source Code</Title>
<ProgramListing>
(define (repl-substring-list? string replace-list pos)
;; Perform repl-substring? with a list of target/replacement pairs
(let loop ((list replace-list))
(let ((target (car list))
(repl (car (cdr list)))
(rest (cdr (cdr list))))
(if (repl-substring? string target pos)
#t
(if (null? rest)
#f
(loop rest))))))
</ProgramListing>
</RefSect1>
</RefEntry>
|