Contents    Page-10    Prev    Next    Page+10    Index   

Transformation Patterns Optimization:


(defpatterns 'opt
  '( ((+ ?x 0)            ?x)
     ((* ?x 0)             0)
     ((* ?x 1)            ?x)
     ((setq ?x (+ ?x 1))  (incf ?x)) ))

Language translation:


(defpatterns 'lisptojava
  '( ((aref ?x ?y)       ("" ?x "[" ?y "]"))
     ((incf ?x)          ("++" ?x))
     ((setq ?x ?y)       ("" ?x " = " ?y))
     ((+ ?x ?y)          ("(" ?x " + " ?y ")"))
     ((= ?x ?y)          ("(" ?x " == " ?y ")"))
     ((and ?x ?y)        ("(" ?x " && " ?y ")"))
     ((if ?c ?s1 ?s2)    ("if (" ?c ")" #\Tab
                           #\Return ?s1
                           #\Return ?s2))