Matching and substitution can combined to transform an input from a pattern-pair: a list of matching pattern and output pattern.
; returns transformed input or #f (define (transform pattern-pair input) (let ((bindings (match? (car pattern-pair) input))) (and bindings (sublis bindings (cadr pattern-pair)))))
> (match? '(- ?x ?x) '(- z z)) ((?x . z))> (match? '(- (+ ?x ?y) (+ ?z ?y)) '(- (+ (age tom) (age mary)) (+ (age bill) (age mary)))) ((?z age bill) (?y age mary) (?x age tom))
> (transform '((- (+ ?x ?y) (+ ?z ?y)) (- ?x ?z)) '(- (+ (age tom) (age mary)) (+ (age bill) (age mary)))) (- (age tom) (age bill))
Contents    Page-10    Prev    Next    Page+10    Index