Cumatru
Cumatru

Reputation: 725

Find facts using multiple values

   (defglobal ?*myGlobal* = 0)

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

)

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

I want to match a fact based on multiple values; the code above matches facts using only one value.

Upvotes: 0

Views: 1841

Answers (1)

Kirt Undercoffer
Kirt Undercoffer

Reputation: 591

You can just use boolean clauses:

(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>)

Upvotes: 3

Related Questions