【发布时间】: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