我正在寻找一种方法来删除基于负面条件的事实。例如,在创建以下事实之后:
CLIPS>
(deffacts Cars
(color red)
(color green)
(color yellow)
(doors three)
(doors five))
CLIPS>
(defrule combinations
(color ?color)
(doors ?doors)
=>
(assert (car ?color ?doors)))
CLIPS> (reset)
CLIPS> (run)
CLIPS> (facts)
f-0 (initial-fact)
f-1 (color red)
f-2 (color green)
f-3 (color yellow)
f-4 (doors three)
f-5 (doors five)
f-6 (car red five)
f-7 (car green five)
f-8 (car yellow five)
f-9 (car red three)
f-10 (car green three)
f-11 (car yellow three)
For a total of 12 facts.
CLIPS> 我正在考虑用下面的语句删除一些事实:
(defrule clear
?q1 <- (car ?color~green five)
=>
(retract ?q1 )
(printout t "Cars cleared " ?q1 crlf)
)这应该删除具有五个门并且颜色不是绿色的汽车。因此,ID f-6和f-8应删除。并打印已删除的事实。
这条语句没有给我一个错误,但如果我执行(运行),它不会收回或打印出该语句。我猜这个条件是不正确的,但是我不知道如何写这个否定的条件。
谢谢
发布于 2016-09-24 19:06:11
我发现了如何正确地编写代码:
(defrule clear
?q1 <- (car ~green five)
=>
(retract ?q1 )
(printout t "Cars cleared " ?q1 crlf)
)希望这能帮助到某个人
https://stackoverflow.com/questions/39674625
复制相似问题