Clips 中的奇怪错误
我想在 Clips 中制作一个程序来生成一个数字的所有分区。首先,我从像他的基本分区一样的数字开始:(1 1 1 1 1)如果是数字5,等等。
(deftemplate partition (multislot p) )
(deffacts facts (p 1 1 1 1 1) )
(defrule adds
(p $?a ?b ?c $?d)
(not (p $?a (+ ?b ?c) $?d))
(not (p (+ ?b ?c) $?a $?d))
(not (p $?a $?d (+ ?b ?c)))
=> (assert (p $?a (+ ?b ?c) $?d))
)
问题是,虽然代码看起来不错,但它在带有“not”的行上有错误 - 其中我指定创建的新分区不应已存在于事实中。 我不知道问题出在哪里,欢迎任何想法。 谢谢
I want to make a program in Clips which generates all the partitions of a number. First of all I start with the number like his basic partition: (1 1 1 1 1) if it is number 5, etc.
(deftemplate partition (multislot p) )
(deffacts facts (p 1 1 1 1 1) )
(defrule adds
(p $?a ?b ?c $?d)
(not (p $?a (+ ?b ?c) $?d))
(not (p (+ ?b ?c) $?a $?d))
(not (p $?a $?d (+ ?b ?c)))
=> (assert (p $?a (+ ?b ?c) $?d))
)
The problem is that although the code seems fine, it has errors on the lines with "not" - where I specify that the new partition created should not already exist in the facts.
I don't know what is the problem, any idea is welcome.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在规则的条件部分,您需要使用 = 运算符来计算表达式并确定它与事实中的值匹配:
In the condition part of a rule, you need to use the = operator to evaluate an expression and determine that it matches a value in the fact: