If statement 剪辑-如何获得特定事实的价值?

If statement 剪辑-如何获得特定事实的价值?,if-statement,clips,If Statement,Clips,我想使用CLIPS创建一个if-then-else函数,但我的条件语句有问题 样本事实: f-0 (initial-fact) f-1 (green-peppers yes) 有没有可能得到青椒的值,这样我就可以设置这样的条件 (if (eq <fact-1> "yes") then (assert) ) 谢谢大家! CLIPS> (clear) CLIPS> (assert (green-peppers yes)) <Fact-1

我想使用CLIPS创建一个if-then-else函数,但我的条件语句有问题

样本事实:

f-0     (initial-fact)
f-1     (green-peppers yes)
有没有可能得到青椒的值,这样我就可以设置这样的条件

(if (eq <fact-1> "yes")
   then 
   (assert)
)
谢谢大家!

CLIPS> (clear)
CLIPS> (assert (green-peppers yes))
<Fact-1>
CLIPS> (assert (green-peppers no))
<Fact-2>
CLIPS> 
(deffunction need (?f)
   (bind ?v (nth$ 1 (fact-slot-value ?f implied)))
   (if (eq ?v yes)
      then TRUE
      else FALSE))
CLIPS> (need 1)
TRUE
CLIPS> (need 2)
FALSE
CLIPS> (clear)
CLIPS> (deftemplate green-peppers (slot need))
CLIPS> (assert (green-peppers (need yes)))
<Fact-1>
CLIPS> (assert (green-peppers (need no)))
<Fact-2>
CLIPS> 
(deffunction need (?f)
   (if (eq (fact-slot-value ?f need) yes)
      then TRUE
      else FALSE))
CLIPS> (need 1)
TRUE
CLIPS> (need 2)
FALSE
CLIPS>