CLIPS Объяснение программирования необходимо

1) Мне нужен способ повторить вопрос, если пользовательский ввод был другим, чем да/нет?

2) Мне нужен способ, позволяющий CLIPS принимать строчные и заглавные буквы.

Я нашел этот образец с помощью Google, но я не уверен, как он работает в определенных строках. Может ли кто-нибудь объяснить мне, как это работает? Или есть лучший способ сделать обе вещи, которые мне нужны.

(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))

person MrWay    schedule 18.09.2017    source источник


Ответы (1)


Псевдокод для функции «задать вопрос»:

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.
person Gary Riley    schedule 18.09.2017