Question

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

Was it helpful?

Solution

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>)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top