我需要用基数测试一个输入。它同意。但是当用户输入基本存在的两个单词时,函数不会通知erro。因此我需要使用"如果那么其他"为了测试这个案例。
错误:[ARGACCES4]函数DeleteOneSynSoftgoal只需要1个参数,但是如果我定义了更多参数,它也会出现错误。
有人可以帮助我。感谢
(deffunction Deleting::DeleteOneSynSoftgoal (?f )"This rule delete one synsoftagoal found in the basis of fact."
(printout t "Enter below the two softgoals field that want to be deleting:" crlf crlf
"the synonyms of the <[TYPE]QUALITY ATTRIBUTE> and the <[TOPIC]SUBJECT/OBJECT LAL> need to be entered one per line." crlf crlf)
(bind ?dsyntype (readline))
(bind ?dsyntopic (readline))
(if (do-for-all-facts((?f synSoftgoal)) (and(eq ?f:syntype ?dsyntype)(eq ?f:syntopic ?dsyntopic)))
then
(retract ?f)
else
(printout t "meta nao encontrada")
(printout t crlf "The SynSoftgoals were successfully deleted" crlf)
)
)
答案 0 :(得分:0)
如果没有满足do-for-all-facts查询的事实,则返回值FALSE。否则,满足查询的最后一个事实的最后一个操作将是返回值,因此如果在(收回?f)操作之后添加值TRUE,则至少do-for-all-facts的返回值为TRUE一个事实被撤回。
目前还不清楚你的目的是制作de faunction的参数,因为它不会在do-for-all-facts查询中的任何函数内部使用,这将影响deffunction参数有自己的定义?f。
CLIPS>
(deftemplate synSoftgoal (slot syntype) (slot syntopic) (slot x))
CLIPS>
(deffacts info
(synSoftgoal (syntype "a") (syntopic "b") (x 1))
(synSoftgoal (syntype "a") (syntopic "c") (x 2))
(synSoftgoal (syntype "a") (syntopic "b") (x 3))
(synSoftgoal (syntype "d") (syntopic "e") (x 4))
(synSoftgoal (syntype "a") (syntopic "b") (x 5))
(synSoftgoal (syntype "a") (syntopic "c") (x 6)))
CLIPS>
(deffunction DeleteOneSynSoftgoal ()
(printout t "dsyntype? ")
(bind ?dsyntype (readline))
(printout t "dsyntopic? ")
(bind ?dsyntopic (readline))
(if (do-for-all-facts ((?f synSoftgoal))
(and (eq ?f:syntype ?dsyntype) (eq ?f:syntopic ?dsyntopic))
(retract ?f)
TRUE)
then
(printout t "The SynSoftgoals were successfully deleted" crlf)
else
(printout t "No SynSoftgoals deleted" crlf)))
CLIPS> (reset)
CLIPS> (facts)
f-0 (initial-fact)
f-1 (synSoftgoal (syntype "a") (syntopic "b") (x 1))
f-2 (synSoftgoal (syntype "a") (syntopic "c") (x 2))
f-3 (synSoftgoal (syntype "a") (syntopic "b") (x 3))
f-4 (synSoftgoal (syntype "d") (syntopic "e") (x 4))
f-5 (synSoftgoal (syntype "a") (syntopic "b") (x 5))
f-6 (synSoftgoal (syntype "a") (syntopic "c") (x 6))
For a total of 7 facts.
CLIPS> (DeleteOneSynSoftgoal)
dsyntype? x
dsyntopic? y
No SynSoftgoals deleted
CLIPS> (facts)
f-0 (initial-fact)
f-1 (synSoftgoal (syntype "a") (syntopic "b") (x 1))
f-2 (synSoftgoal (syntype "a") (syntopic "c") (x 2))
f-3 (synSoftgoal (syntype "a") (syntopic "b") (x 3))
f-4 (synSoftgoal (syntype "d") (syntopic "e") (x 4))
f-5 (synSoftgoal (syntype "a") (syntopic "b") (x 5))
f-6 (synSoftgoal (syntype "a") (syntopic "c") (x 6))
For a total of 7 facts.
CLIPS> (DeleteOneSynSoftgoal)
dsyntype? a
dsyntopic? b
The SynSoftgoals were successfully deleted
CLIPS> (facts)
f-0 (initial-fact)
f-2 (synSoftgoal (syntype "a") (syntopic "c") (x 2))
f-4 (synSoftgoal (syntype "d") (syntopic "e") (x 4))
f-6 (synSoftgoal (syntype "a") (syntopic "c") (x 6))
For a total of 4 facts.
CLIPS> (DeleteOneSynSoftgoal)
dsyntype? d
dsyntopic? e
The SynSoftgoals were successfully deleted
CLIPS> (facts)
f-0 (initial-fact)
f-2 (synSoftgoal (syntype "a") (syntopic "c") (x 2))
f-6 (synSoftgoal (syntype "a") (syntopic "c") (x 6))
For a total of 3 facts.
CLIPS>