Contents    Page-10    Prev    Next    Page+10    Index   

Substitution

(subst x y z) (``substitute x for y in z'') can be used to make new code from a pattern.


>(subst pi 'pi '(* pi (* r r)))
(* 3.14159265 (* R R))

>(subst 1 'i '(aref x (+ -8 (* 8 i))))
(AREF X (+ -8 (* 8 1)))

(sublis alist form) makes multiple substitutions:


>(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)