首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在一个defrule中定义一个全局变量,并在剪辑中的另一个defrule中使用它?

如何在一个defrule中定义一个全局变量,并在剪辑中的另一个defrule中使用它?
EN

Stack Overflow用户
提问于 2018-06-02 02:08:24
回答 1查看 315关注 0票数 0

我在剪辑中写了这些代码,但它不能工作。上面写着“局部变量不能被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))
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50648912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档