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