(rule (append-to-form () ?y ?y))
(rule (append-to-form (?u . ?v) ?y (?u . ?z))
(append-to-form ?v ?y ?z))
;;; Query input:
(append-to-form (a b) (c d) ?z)
;;; Query results:
(append-to-form (a b) (c d) (a b c d))
This rule had puzzled me. Now I known what happen? Firstly, (append-to-form ?a ?b ?c) means
the result ?c is ?a + ?b. (rule (append-to-form () ?y ?y)) is easy to understand. A empty list
is appended to a list. Let's look at the second sub rule.
(rule (append-to-form (?u . ?v) ?y (?u . ?z))
(append-to-form ?v ?y ?z))
A list can be considered as the 'car' and 'cdr' parts. So, the (?u . ?v) represented that two
parts in a list. The '?u' is the 'car' part and the '?z' is the rest of a new list appended. How
to get the '?z'? Append the 'cdr' part of the first list and a list -- ?y.
It is so easy and intuitive.