从多字段访问插槽中的功能是否无效

问题描述

| 我有这个函数,它基于多个多字段事实的多个时隙来计算一些值。 因为涉及到很多插槽,并且函数中需要所有插槽,所以我在想是否可以将整个事实传递给函数并访问其中的插槽, 像这样:
(deftemplate a-fact
    (slot id)
    (slot name)
    (slot ...)
    ...
)

(deffunction a-funciton (?factadr)
    (switch ?factadr:name
        (case bla then ...)
    )

    (return ?calculated-value)
)

(defrule a-rule
    ?factadr <- (a-fact (id ?i))
    =>
    (if (> **(a-function ?factadr) 20) then ... )
)
在此示例中,我看到了这个?fact-adrres:slot-name,并认为它可以工作,但没有用。那么,有可能并且如何做到这一点?
(bind ?facts (find-all-facts ((?f attribute))
                               (and (eq ?f:name wine)
                                    (>= ?f:certainty 20))))
使用片段6.3。     

解决方法

        使用事实槽值函数。
CLIPS> 
(deftemplate a-fact
   (slot id)
   (slot name))
CLIPS>  
(defrule a-rule
   ?f <- (a-fact)
   =>
   (printout t (fact-slot-value ?f id) \" \" (fact-slot-value ?f name) crlf))
CLIPS> (assert (a-fact (id 3) (name x)))
<Fact-1>
CLIPS> (assert (a-fact (id  7) (name y)))
<Fact-2>
CLIPS> (run)
7 y
3 x
CLIPS>
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...