Search code examples
clipsexpert-system

Testing for presence in a multifield - CLIPS


I want to add a condition to the LHS of a rule which tests if a certain symbol appears somewhere in the multislot of a template.

For example, in the code below I would like to substitute the comment with whatever expression makes this work.

(deftemplate foo
(slot field
    (type STRING)
   )
(multislot multifield
    (type INTEGER)
  )
)

(deftemplate bar
(slot field
   (type INT)
  )
)

(defrule rule
(foo (field ?f1) (multifield $?mf1))
(bar (field ?f2))
; IF f2 IS AN ELEMENT OF mf1
=>
(assert (relation f1 f2))
)

What is the syntax here?


Solution

  • I needed to use the member$ function!

    (test (member$ ?f2 ?mf1))