CLIPS模式匹配中的数字相等性测试失败?

编程入门 行业动态 更新时间:2024-10-09 02:24:48
本文介绍了CLIPS模式匹配中的数字相等性测试失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的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模式匹配中的数字相等性测试失败?

本文发布于:2023-11-25 10:16:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629355.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模式   数字   测试   CLIPS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!