Substitution

The function subst makes a new tree structure with a specified substitution. subst is standard in Common Lisp.

(subst new old tree ) substitutes new for old in tree.


(subst 'jones 'name '(dear mr name))

= (dear mr jones)

(subst 5.0 'radius '(* 3.14159 (expt radius 2)))

= (* 3.14159 (expt 5.0 2))

(subst 'socrates 'x '(if (human x) (mortal x)))

= (if (human socrates) (mortal socrates))

(subst 'lollipop 'rose '(rose is a rose is a rose))

= (lollipop is a lollipop is a lollipop)

Contents    Page-10    Prev    Next    Page+10    Index