【问题标题】:Cant implement function on Bind in CLIPS无法在 CLIPS 中实现 Bind 功能
【发布时间】:2020-07-22 15:33:41
【问题描述】:
(deffunction slabV10071 ( ?totalQuantity ?quantityBuilder )
    (bind ?promoQuantities (integer (/ ?totalQuantity 6)))
    if(>= ?totalQuantity 12) then
    (assert(Output (promoId V10071)(promotionTypeCode 1)(productIds 3089 2264 2090 )(quantities ?quantityBuilder)(uom EA)(promoQuantities ?promoQuantities)(values  1666.6666666)(rewardId  3089,2264,2090)(repeatingRange 1)(proRata N)(exclusionFlag 1)(sequenceNumber 3335)(effectiveFrom 2020-05-27)))
    (return))(bind ?promoQuantities (integer (/ ?totalQuantity 12)))
    if(>= ?totalQuantity 6) then
    (assert(Output (promoId V10071)(promotionTypeCode 1)(productIds 3089 2264 2090 )(quantities ?quantityBuilder)(uom EA)(promoQuantities ?promoQuantities)(values  1700)(rewardId  3089,2264,2090)(repeatingRange 1)(proRata N)(exclusionFlag 1)(sequenceNumber 3335)(effectiveFrom 2020-05-27)))
    (return)))
(defrule V10071
(exists (Product(productId 3089)(quantity ?q&:(> ?q 1))(date ?orderDate&:(<= 20200527 ?orderDate 20201231))))
=>
(bind ?totalQuantity 0)
(bind ?quantityBuilder "")
(do-for-all-facts ((?p Product))
(or (eq ?p:productId 3089)
(eq ?p:productId 2264)
(eq ?p:productId 2090)
)
(bind (str-cat ?quantitybuilder ?p:quantity " " ))
(bind ?totalQuantity (+ ?totalQuantity ?p:quantity)))
(if(>= ?totalQuantity 1) then
(slabV10071 ?totalQuantity ?quantityBuilder)))

这是代码。该slabV10071 功能工作正常。但是在规则中我得到了错误

[PRNTUTIL2] 语法错误:检查绑定函数的适当语法。

[PRNTUTIL2] 语法错误:检查事实集查询函数的适当语法。

请帮忙。

【问题讨论】:

    标签: rules rule-engine clips


    【解决方案1】:

    错误消息显示您的规则中发生错误的位置:

    ERROR:
    (defrule MAIN::V10071
       (exists
            (Product (productId 3089) (quantity ?q&:(> ?q 1)) (date ?orderDate&:(<= 20200527 ?orderDate 20201231))))
       =>
       (bind ?totalQuantity 0)
       (bind ?quantityBuilder "")
       (do-for-all-facts ((?p Product))
          (or (eq ?p:productId 3089) (eq ?p:productId 2264) (eq ?p:productId 2090))
          (bind(
    

    这是导致错误的代码行:

    (bind (str-cat ?quantitybuilder ?p:quantity " " ))
    

    您没有提供函数调用将绑定到的变量。这可能就是你想要的:

    (bind ?quantitybuilder (str-cat ?quantitybuilder ?p:quantity " " ))
    

    【讨论】:

      猜你喜欢
      • 2017-05-03
      • 2021-08-22
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 2014-05-08
      • 2013-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多