【问题标题】:How to add fact in CLIPS如何在 CLIPS 中添加事实
【发布时间】:2017-12-03 19:44:21
【问题描述】:

我在那里找到了函数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

有我的汽车标志模板:

(deftemplate car-mark (插槽名称) )

如何正确添加新事实并考虑用户输入(是 - 添加,否 - 不添加)?

【问题讨论】:

    标签: clips


    【解决方案1】:
    (assert (car-mark (name "foo")))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多