So I'm trying to build a program that takes user's input by displaying a message on the screen “Enter your subject”.
In the second rule, I'm to mention subject names “artificial intelligence”, “operating system” and “compiler construction” and check that entered subject from the first rule matches with the mentioned subjects by displaying this message on the screen. “Your entered subject is true”.
Here is the code:
(deftemplate subject
(slot subject)
(slot artificial intelligence)
(slot operating system)
(slot compiler construction))
(defrule reading-input
(printout t "Enter your subject:")
(assert(var(read))))
(defrule checking-input
(var? artificial intelligence)
(var? operating system)
(var? compiler construction)
(com(artificial intelligence ? artificial intelligence))
(test(=?artificial intelligence ? artificial intelligence))
(test(=?operating system ? operating system))
(test(=? compiler construction ? compiler construction))
(=>
printout t "Your entered subject is true:"))
test(=?
be a cause of the trouble? It's an inconsistency in the layout, at any rate. Otherwise, could the newline after(=>
be the cause of the trouble? Just guesses from someone who'd never heard of CLIPS until this question crossed their path. It would be easier to see the structure if there was a blank line before eachdefrule
line to segregate different units. But I don't know if CLIPS is space sensitive. – Jonathan Leffler