我的CLIPS文件中有以下规则:
I have this following rule in my CLIPS file:
(defrule check-final (declare (salience 12)) ?scnt <- (set-count (value ?v) (class ?c)) (test (= ?v ?*total*)) => (printout T ?*total* " == " ?v crlf) )我得到以下奇怪的输出:
And I get the following strange output:
CLIPS>(run) 14 == 9 5 == 2这怎么可能????
推荐答案只要声明或修改了事实set-count,就会发生与此规则的模式匹配.在调用run的过程中,此规则会在之后的某个时间触发.这两个过程可以在时间上广泛分离. ?*v*的值当然可以在很长一段时间内发生变化.
Pattern matching for this rule occurs whenever the fact set-count is asserted or modified. The rule is fired some time afterwards, during the call to run. These two processes can be widely separated in time. The value of ?*v* can of course change during that long period of time.
关键是要意识到他打印的结果将反映发生模式匹配的时期的?v值,而?*total*是打印结果时的值.由于?*total*自模式匹配以来可能已经发生了任意变化,因此不能保证在规则实际触发时它等于?v.
The key is to realize that he printed results will reflect the value of ?v from the the epoch during which pattern matching happened, while ?*total* will be the value when the results are printed. Since ?*total* may have seen arbitrary changes since the pattern matching, there's no guarantee that it will be equal to ?v when the rule actually fires.
更多推荐
CLIPS模式匹配中的数字相等性测试失败?
发布评论