1) I need a way to repeat the question if the user input was other than yes/no?
2) I need a way to allow CLIPS to accept small and capital letters.
I found this sample by googling but im not so sure how its works on certain lines. Can anyone explained to me how this works? Or there is a better a way to did both of things i needed.
(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))
The pseudo-code for the ask-question function: