我不想匹配jess-object的值(String),而比较值是字符串和另一个字段的组合。
这是一个简单的(“可运行的”)示例:
(defclass Person (is-a :THING) (slot name (type string)) (slot email (type string)))
(mapclass Person)
(make-instance Andy of Person (name "Andy") (email "Andy@mail"))
(defrule search
(object (OBJECT ?tmpPerson)
(is-a Person)
(email (str-cat (slot-get ?tmpPerson name) "@mail"))
)
=>
(print t "found")
)
但是代码不能在JessTab中编译。看来,在字段名称“ name ”之后,“(”是不允许的。
错误:
Jess reported an error in routine Jesp.parsePattern.
Message: Bad slot value at token '('.
Program text: ( defrule search ( object ( OBJECT ?tmpPerson ) ( is-a Person ) ( name ( at line 5.
我该如何解决这个问题?
提前致谢
答案 0 :(得分:1)
要将模式与函数返回的值匹配,必须在函数调用之前加上等号 - 即"(name =(str-cat ..."