subst is copy-tree with Substitution

copy-tree makes a copy of tree structure: it makes copies of pairs and reuses the same values for non-pairs.

; Copy a tree structure
(define (copy-tree tree)
  (if (pair? tree)
      (cons (copy-tree (car tree))
            (copy-tree (cdr tree)))

subst copies a structure, but with substitution of elements that match old:

(define (subst new old tree)
  (if (pair? tree)
      (cons (subst new old (car tree))
            (subst new old (cdr tree)))
      (if (eqv? old tree)

Contents    Page-10    Prev    Next    Page+10    Index