【问题标题】:CLIPS Programming explained neededCLIPS 编程需要解释
【发布时间】:2018-02-27 08:21:02
【问题描述】:

1) 如果用户输入不是是/否,我需要一种方法来重复问题?

2) 我需要一种方法让 CLIPS 接受大小写字母。

我通过谷歌搜索找到了这个示例,但我不太确定它在某些行上是如何工作的。谁能向我解释这是如何工作的?或者有更好的方法来做我需要的两件事。

(deffunction ask-question (?question $?allowed-values)
   (printout t ?question)
   (bind ?answer (read))
   (if (lexemep ?answer) 
       then (bind ?answer (lowcase ?answer)))
   (while (not (member ?answer ?allowed-values)) do
      (printout t ?question)
      (bind ?answer (read))
      (if (lexemep ?answer) 
          then (bind ?answer (lowcase ?answer))))
   ?answer)

(deffunction yes-or-no-p (?question)
   (bind ?response (ask-question ?question yes no y n))
   (if (or (eq ?response yes) (eq ?response y))
       then yes 
       else no))

【问题讨论】:

    标签: clips


    【解决方案1】:

    ask-question 函数的伪代码:

    Print the question.
    Get the answer.
    
    If 
      The answer is a symbol or string
    Then 
      Convert the answer to lower case.
    End if
    
    While the answer is not one of the allowed values
    
       Print the question.
       Get the answer.
    
       If 
         The answer is a symbol or string
       Then 
         Convert the answer to lower case.
       End if
    
    End while
    
    Return the answer.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多