Testing for Presence in a Multifield - Clips

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?

1 Answer

I needed to use the member$ function!

(test (member$ ?f2 ?mf1))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.