Non-recursively applies a list of substring substitutions to a string.
Earlier key/value pairs take precedence over later ones, and no substitutions are reapplied to the result of other substitutions.
Function:
(defun dumb-str-sublis-iter (remainder alist x start end len) (b* (((when (atom remainder)) (if (or (not (int= start 0)) (not (int= end len))) (subseq x start end) x)) ((cons old-str new-str) (car remainder)) (loc (search old-str x :start2 start :end2 end)) ((unless loc) (dumb-str-sublis-iter (cdr remainder) alist x start end len)) (prefix-rw (dumb-str-sublis-iter (cdr remainder) alist x start loc len)) (suffix-rw (dumb-str-sublis-iter alist alist x (+ loc (length old-str)) end len))) (if (and (string-equal prefix-rw "") (string-equal suffix-rw "")) new-str (concatenate 'string prefix-rw new-str suffix-rw))))
Function:
(defun dumb-str-sublis (alist str) (let ((len (length str))) (dumb-str-sublis-iter alist alist str 0 len len)))