我们如何在另一个 defrule 中调用一个 defrule?

问题描述

我对 CLIPS 完全陌生,我想知道我们如何在另一个 defrule 中调用 defrule。 例如,如果一个规则执行诸如打印或交换之类的常规工作,而另一条规则想在自己进行模式匹配后调用它;第二条规则如何在其模式匹配部分调用一个规则? 谢谢

解决方法

通过断言一个规则中的一个事实来激活另一个规则来链接规则。

         CLIPS (6.31 6/12/19)
CLIPS> 
(defrule start
   =>
   (assert (r1)))
CLIPS> 
(defrule rule-1
   (r1)
   =>)
CLIPS> (watch rules)
CLIPS> (watch activations)
CLIPS> (watch facts)
CLIPS> (agenda)
0      start: *
For a total of 1 activation.
CLIPS> (run)
FIRE    1 start: *
==> f-1     (r1)
==> Activation 0      rule-1: f-1
FIRE    2 rule-1: f-1
CLIPS>