Search code examples
clipsexpert-systeminference-engine

Taking all values of multislot slot using the fact-address in CLIPS


Is it possible somehow in clips to pick up all values in multislot slot using the factaddress of a fact? For instance:

(deftemplate MAIN::simplecause
   (multislot coraxinfo (type INTEGER) (default 0))
   (multislot changeinfo (type SYMBOL) (default undefined)))

(deftemplate MAIN::finalcause   
   (multislot coraxinfo (type INTEGER) (default 0))
   (multislot changeinfo (type SYMBOL) (default undefined)))

(deftemplate MAIN::finalcausefinal  
   (multislot coraxinfo (type INTEGER) (default 0))
   (multislot changeinfo (type SYMBOL) (default undefined))
   (slot casecount (type INTEGER) (default 2)))

And I have a function called count-coraxes which receives multislot value in input, so I try to write a rule of such kind:

(defrule final_cause_reason_count
   ?f <- (finalcause (coraxinfo ?corax $?) (changeinfo ?change $?))
   (simplecause (coraxinfo $? ?corax $?) (changeinfo $? ?change $?))
   =>
   (assert (finalcausefinal(coraxinfo ?f:coraxinfo) (changeinfo ?f:changeinfo) (casecount (count-coraxes ?f:coraxinfo)))))

I assumed that ?f:coraxinfo will pull all values in coraxinfo slot for fact with factadress ?f but looks like it is not the case. Is it not possible at all?


Solution

  • Per Gary's comment:

    The shorthand syntax for retrieving slot values can only be used in the fact-set query functions. Use "(fact-slot-value ?f changeinfo)" instead of ?f:changeinfo