【发布时间】:2019-12-12 10:35:34
【问题描述】:
我是剪辑规则引擎的新手,必须在移动应用程序的剪辑中进行跟踪。 如果一个人购买 x 数量的产品 A,给他 y 折扣。
以下是我编写的代码,用于首先检查我的 productid 是否在订单中。
(deftemplate Producttemp
(slot productid (type INTEGER))
(slot umid)
(slot quantity (type INTEGER))
)
(deffacts orders
(Producttemp (productid 123) (umid CG) (quantity 4))
(Producttemp (productid 456) (umid CG) (quantity 2))
)
(defrule checkorder
=>
(printout t "Enter the productid: ")
(bind ?p1 (readline))
(printout t "Enter another quantity: ")
(bind ?p2 (readline))
(do-for-all-facts ((?o Producttemp))
(and (eq ?p1 ?o:p1)
(eq ?p2 ?o:p2))
(printout t ?p1 " is a " ?o: productid" in order " ?p2 crlf)))
)
我收到以下错误。
Defining defrule: checkorder
[PRCCODE3] Undefined variable o: referenced in RHS of defrule.
【问题讨论】:
标签: clips