Transformation

(defun transf (rule input)
  (let ((bindings (match (first rule) input))
        (test (third rule)))
    (if (and bindings
             (or (null test)
                 (eval (sublisq bindings test))))
        (progn
          (dolist (var (fourth rule))
            (push (cons (car var)
                        (eval (sublisq bindings
                                    (cadr var))))
                  bindings) )          
          (sublis bindings (second rule)))
        'match-failure) ))

; sublis, quoting value of bindings
(defun sublisq (bindings form)
  (sublis
    (mapcar #'(lambda (x)
                (cons (car x) (kwote (cdr x))))
            bindings)
    form) )

(defun kwote (x) (if (constantp x) x (list 'quote x) ) )

Contents    Page-10    Prev    Next    Page+10    Index