2 Patterns and rules
(rule name patterns action) -> rule? |
name : symbol? |
patterns : (listof pattern?) |
action : (-> match-record? (listof action?)) |
(match-record vars elements) -> match-record? |
A pattern mirrors the element layout: (monkey location (? loc) holds _). Slots are constants, the wildcard _, or variables (? name). The same variable in one pattern demands equal values; across a rule’s patterns it joins them.
The right-hand side receives the matched variable bindings and the matched elements themselves, and returns actions:
(make-action class slots) ; a new fact |
(remove-action element) ; the fact is gone |
(modify-action element new-slots) ; remove + make: a fresh fact |
Everything the patterns cannot say, the procedure says with the full language. modify is remove plus make by design: a changed fact is a new event, and downstream recency sees it.