REDUCE

5.5 Substitutions

(subst U:any V:any W:any): any expr
Returns the result of substituting U for all occurrences of V in W. Copies all of W which is not replaced by U. The test used is equal.
    (de subst (u v w)  
      (cond ((null w) nil)  
            ((equal v w) u)  
            ((not (pairp w)) w)  
            (t (cons (subst u v (car w)) (subst u v (cdr w))))))

(substip U:any V:any W:any): any expr
Destructive subst.

(sublis X:a-list Y:any): any expr
This performs a series of substs in parallel. The value returned is the result of substituting the cdr of each element of the a-list X for every occurrence of the car part of that element in Y. Sublis is not quite the correct function for arbitrary code substitutions. As illustrated below, substitutions may enter places you might wish they did not.
    (de sublis (x y)  
      (if (not (pairp x))  
        y  
        (let ((u (assoc y x)))  
          (cond ((pairp u) (cdr u))  
                ((not (pairp y)) y)  
                (t (cons (sublis x (car y)) (sublis x (cdr y))))))))  
 
    1 lisp> (sublis '((x . 100)) '(list 'x 'is x))  
    (list (quote 100) (quote is) 100)

(subla U:a-list V:any): any expr
Eq version of sublis; replaces atoms only.