0
我的问题是我想保存答案的步骤和结束显示结果,但它不起作用。根据变量显示事实
我的代码:
(defglobal
?*name* = empty
?*country* = empty
?*age* = empty
)
(deffacts persons
(person John Chile 20 3000)
(person Jacob Mexico 20 5500)
(person Jacob Chile 20 3300)
(person John Chile 20 8400)
)
(defrule Hello
=>
(printout t "Name:" crlf)
(bind ?*name* (read))
(assert (step 1))
)
(defrule Step1
(step 1)
=>
(printout t "Country:" crlf)
(bind ?*country* (read))
(assert (step 2))
)
(defrule Step2
(step 2)
=>
(printout t "Age:" crlf)
(bind ?*age* (read))
(assert (step 3))
)
(defrule Step3
(step 3)
(person ?name ?country ?age ?money)
=>
(printout t ?name "," ?country "," ?age "," ?money crlf)
)
我的解决办法:
(defrule Step3
(step 3)
(person ?name&?*name* ?country&?*country* ?age&?*age* ?money)
=>
(printout t ?name "," ?country "," ?age "," ?money crlf)
)
但是这种解决方案会导致错误。
也许最好在每次选择后删除事实?
你能告诉我为什么加载时返回False吗? //但代码有效 – Enteee
文件中有错误。可能是构造之间的额外字符。该文件应该只包含deftemplates,deffacts和defrules。不知道你放在文件中的内容或加载时输出的内容,我只能推测出问题所在。 –
我必须在加载之前使用(清除)? – Enteee