我在剪辑中写了这些代码,但它不能工作。上面写着“局部变量不能被deffact访问”。我还想在其他defrules中使用number1和number2的值。如何在规则中将这些变量定义为全局变量?
(deffunction calculation1
(?x ?y)
(+ ?x ?y))
(defrule rule1
=>
(printout t "What is the first number?")
(bind ?number1 (read))
(assert (number-1 ?number1))
(printout t "What is the second number?")
(bind ?number2 (read))
(assert (number-2 ?number2))
(bind ?theirsum (calculation1 ?number1 ?number2))
(printout t "The sum is " ?theirsum crlf))
(deffacts data
(first num1 ?number1
second num2 ?number2))
https://stackoverflow.com/questions/50648912
复制相似问题