【发布时间】:2020-06-16 10:57:20
【问题描述】:
我想根据事实添加并打印三种产品的总数量。如果数量大于 1,我也需要对产品 1 进行检查。
(defrule sum_of_quantity
(or
(Product (productNumber 1)(quantity ?quantity0))
(Product (productNumber 2)(quantity ?quantity1))
(Product (productNumber 3)(quantity ?quantity2)))
=>
(bind ?totalQuantity (integer(+ ?quantity0 ?quantity1 ?quantity2)))
(printout t "TotalQuantity is " ?totalQuantity crlf))
I am actually new to clips and is finding it difficult to write rules
【问题讨论】:
-
当您尝试运行此代码时会发生什么?为什么这是错的?请完整引用收到的任何错误,或者,如果它运行但输出错误,请显示所需的与当前输出。
-
我得到的错误是 Defrule 的 RHS 中引用的未定义变量数量 1。错误: (defrule MAIN::sum_of_quantity (或 (Product (productNumber 1) (quantity ?quantity0)) (Product (productNumber 2) (quantity ?quantity1)) (Product (productNumber 3) (quantity ?quantity2))) => ( bind ?totalQuantity (integer (+ ?quantity0 ?quantity1 ?quantity2))) (打印输出 t "TotalQuantity is " ?totalQuantity crlf))
标签: rules rule-engine clip clips