我在这里阅读了如何在剪辑规则的 lhs 上调用 python 函数。
现在我有以下规则:
(defrule python_func_lhs "comment me"
(object (is-a clips_TEST_CLASS) (some_slot ?some_slot_value))
(test (eq (python-call python_print (str-cat "some_slot: " ?some_slot_value)) TRUE))
=>
;(assert (do_something))
)
我的问题是python函数被调用了两次,第一次打印
some_slot:无
接着
some_slot: some_slot_value
似乎包含 python 函数的第二个规则部分不会“等待”匹配 LHS 规则的第一部分。
一旦匹配 LHS 规则的第一部分,如何让剪辑只调用一次 python 函数?换句话说,我想等到?some_slot_value
变量有值。
如果可能的话,我想避免创建多个规则并使用“控制事实”。