如何在 CLIPS 中添加事实
How to add fact in CLIPS
我在那里找到了函数 CLIPS Validate Text Entry,我想这样扩展它:
(deffunction ask-question (?mark ?question $?allowed-values)
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer))
**(assert car-mark(name ?mark))**
) (while (not (member ?answer ?allowed-values)) do
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer))
**(assert car-mark(name ?mark))**
)
) ?answer)
因此,如果用户输入 yes/y,我计划在我的事实中添加新的汽车标记 - 否则 - 不添加事实。但是剪辑给出了错误:
[PRNTUTIL2] 语法错误:检查 RHS 模式的适当语法。
错误:
(deffunction MAIN::ask-question
(?mark ?question $?allowed-values)
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then
(bind ?answer (lowcase ?answer))
(assert car-mark
有我的车标模板:
(detemplate car-mark
(插槽名称)
)
如何正确添加新事实并考虑用户输入(是 - 添加,否 - 不添加)?
(assert (car-mark (name "foo")))
我在那里找到了函数 CLIPS Validate Text Entry,我想这样扩展它:
(deffunction ask-question (?mark ?question $?allowed-values)
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer))
**(assert car-mark(name ?mark))**
) (while (not (member ?answer ?allowed-values)) do
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then (bind ?answer (lowcase ?answer))
**(assert car-mark(name ?mark))**
)
) ?answer)
因此,如果用户输入 yes/y,我计划在我的事实中添加新的汽车标记 - 否则 - 不添加事实。但是剪辑给出了错误:
[PRNTUTIL2] 语法错误:检查 RHS 模式的适当语法。
错误:
(deffunction MAIN::ask-question
(?mark ?question $?allowed-values)
(printout t ?question)
(bind ?answer (read))
(if (lexemep ?answer)
then
(bind ?answer (lowcase ?answer))
(assert car-mark
有我的车标模板:
(detemplate car-mark (插槽名称) )
如何正确添加新事实并考虑用户输入(是 - 添加,否 - 不添加)?
(assert (car-mark (name "foo")))