;; This is an example of a _good_ JESS function (i.e., something that ;; makes more sense written in procedural style than in declarative style). ;; ;; This function prompts the user with ?qstring, and then validates the ;; response to be either y/yes or n/no (case insensitive). It re-prompts if ;; an invalid response is given. (deffunction ask-question-yn "Ask a yes/no question and return TRUE/FALSE" (?qstring) (bind ?success FALSE) (while (not ?success) do (printout t ?qstring) (bind ?reply (read)) (if (member$ (lowcase ?reply) (create$ "y" "yes")) then (bind ?reply TRUE) (bind ?success TRUE) else (if (member$ (lowcase ?reply) (create$ "n" "no")) then (bind ?reply FALSE) (bind ?success TRUE) else (printout t "Please answer yes or no." crlf)))) ?reply)