sublis does Multiple Substitutions

(sublis alist tree) copies tree with substitution of elements that are specified in the association list alist.

(sublis '((rose . lollipop) (smell . taste))
        '(a rose by any other name
          would smell as sweet))

= (a lollipop by any other name would taste as sweet)

(define (sublis alist tree)
  (if (pair? tree)
      (cons (sublis alist (car tree))
            (sublis alist (cdr tree)))
      (if (assv tree alist)
          (cdr (assv tree alist))

Contents    Page-10    Prev    Next    Page+10    Index