More Complex Rules

It is desirable to augment rewrite rules in two ways:

  1. Add a predicate to perform tests on the input; only perform the transformation if the test succeeds:
    (and (numberp ?n) (> ?n 0))

  2. Create new variables by running a program on existing variables:
    
    (transf '((intersection
               (subset (function (lambda (?x) ?p))
                       ?s)
               (subset (function (lambda (?y) ?q))
                       ?s))
              (subset (function (lambda (?x)
                        (and ?p ?qq)))
                      ?s)
              t
              ((?qq (subst ?x ?y ?q))) )
      '(intersection
         (subset #'(lambda (w) (rich w)) people)
         (subset #'(lambda (z) (famous z)) people)))
    
    (SUBSET #'(LAMBDA (W) (AND (RICH W) (FAMOUS W)))
            PEOPLE))
    

Contents    Page-10    Prev    Next    Page+10    Index