我已经在jess中编写了这段代码,但我一直遇到这个错误,我不明白为什么?
(deffacts prices (price apple 125) (price chips 45) (price cola 110) (price egg 700))
(defrule createBill (buy ?n $?) => (assert (bill ?n 0)))
(deffunction getTotalPrice (?list)
(bind ?result 0) (foreach ?product $?products
(price ?product ?price)
(bind ?result (+ ?result ?price)))
(return ?result))
(defrule calculate ?i<-(bill ?n $?) (buy ?n $?products) => (retract ?i) (bind ?result (getTotalPrice $?products))(assert (bill ?n ?result)))
(reset)
(assert (buy yaser cola egg))
(run)
我得到这个错误???
Jess reported an error in routine Funcall.execute
while executing (price ?product ?price)
while executing (foreach ?product $?products (price ?product ?price) (bind ?result (+ ?result ?price)))
while executing defrule MAIN::calculate
while executing (run).
Message: Undefined function price.
Program text: ( run ) at line 41.
问题是Jess正在寻找一个名为 price 的函数,但我想使用(price ... ...)
任何帮助都是好的事实 :) Yaser。