repl-substring-list?

Name

repl-substring-list? -- Perform repl-substring? with a list of target/replacement pairs

Synopsis

(repl-substring-list? string replace-list pos)

Description

Returns #t if any target in replace-list occurs at pos in string.

string

The string in which replacement should be tested.

replace-list

A list of target/replacement pairs. This list is just a list of strings, treated as pairs. For example, ("was" "x" "is" "y"). In this example, was may be replaced by x and is may be replaced by y.

pos

The location within string where the test will occur.

Example

(repl-substring-list? "this is it" ("was" "x" "is" "y") 2) returns #t: "is" could be replaced by "y".

Author

Norman Walsh, <ndw@nwalsh.com>

Source Code

(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))))))