Transformation by Patterns
Matching and substitution can be combined to transform an input using a transformation rule transrule: a list of an input pattern and an output pattern.
(defn transform [transrule input]
(let [bindings (match (first transrule)
input)]
(if bindings
(sublis bindings (second transrule)) ) ))
>(transform '( (I aint got no ?x)
(I do not have any ?x) )
'(I aint got no bananas) )
(I do not have any bananas)