Multiple Substitutions

The function (sublis alist form) makes multiple substitutions simultaneously:


>(sublis '((rose peach) (smell taste))
         '(a rose by any other name
           would smell as sweet))

(A PEACH BY ANY OTHER NAME WOULD TASTE AS SWEET)


; substitute in z with bindings in alist
(defun sublis (alist z)
  (let (pair)
    (if (consp z)
        (cons (sublis alist (first z))
              (sublis alist (rest z)))
        (if (setq pair (assoc z alist))
            (second pair)
            z)) ))

Contents    Page-10    Prev    Next    Page+10    Index