<RefEntry id="string-replace-list"> <!-- This file is generated automatically from the DSSSL source. --> <!-- Do not edit this file! --> <?html-filename string-replace-list.html> <RefMeta> <RefEntryTitle>string-replace-list</RefEntryTitle> <RefMiscInfo Role="file">dblib.dsl</RefMiscInfo> </RefMeta> <RefNameDiv> <RefName>string-replace-list</RefName> <RefPurpose>Replace a list of target substrings in a string</RefPurpose> </RefNameDiv> <RefSynopsisDiv><Title>Synopsis</Title> <Synopsis> (string-replace-list string replace-list) </Synopsis> </RefSynopsisDiv> <RefSect1><Title>Description</Title> <para> Replaces, in <literal>string</literal>, all occurances of each target in <literal>replace-list</literal> with its replacement.</para> </RefSect1> <RefSect1><Title>Author</Title> <para> Norman Walsh, <ndw@nwalsh.com> </para> </RefSect1> <RefSect1><Title>Source Code</Title> <ProgramListing> (define (string-replace-list string replace-list) ;; Replace a list of target substrings in a string (let loop ((str string) (pos 0)) (if (>= pos (string-length str)) str (loop (repl-substring-list str replace-list pos) (if (repl-substring-list? str replace-list pos) (+ (string-length (repl-substring-list-repl str replace-list pos)) pos) (+ 1 pos)))))) </ProgramListing> </RefSect1> </RefEntry>