Transformation by Patterns

Matching and substitution can be combined to transform an input from a pattern-pair: a list of an input pattern and an output pattern.


(defun transform (pattern-pair input)
  (let (bindings)
    (if (setq bindings
              (match (first pattern-pair)
                     input))
        (sublis bindings
                (second pattern-pair))) ))


>(transform '((I aint got no ?x)
              (I do not have any ?x))

            '(I aint got no bananas))

(I DO NOT HAVE ANY BANANAS)

Contents    Page-10    Prev    Next    Page+10    Index