使用多个值查找事实

时间:2012-10-21 20:09:43

标签: clips

   (defglobal ?*myGlobal* = 0)

    (deftemplate myTemp
        (slot one)
        (slot second)
        (slot third)
        (slot fourth)

 (find-fact ((?p myTemp)) (eq ?p:one aValue))

我想基于多个值来匹配事实;上面的代码只使用一个值匹配事实。

1 个答案:

答案 0 :(得分:2)

您可以使用布尔子句:

(assert (myTemp (one asd) (second jhg))
        (myTemp (one asd) (second kjh))
        (myTemp (one bvc) (second jhg))
        (myTemp (one bvc) (second jhg) (third qwe)))

(find-fact ((?p myTemp)) (or (eq ?p:one bvc) (eq ?p:third qwe))
(<Fact-4>)

(find-fact ((?p myTemp)) (or (eq ?p:one bvc) (eq ?p:second jhg))
(<Fact-1>)

(find-all-fact ((?p myTemp)) (or (eq ?p:one bvc) (eq ?p:second jhg))
(<Fact-1> <Fact-3> <Fact-4>)