I have been trying to work this out, and I need some help please.

 

This works:

 

(deftemplate suffix (multislot value))

(assert (suffix (value "md", "phd", "jr")))

 

(defrule check-suffix

      ?fact1 <- (a ?x)

      ?fact2 <- (suffix)

      (a ?x)

      (not (suffix (value $?before ?x $?after)))

      =>

      (printout t "Suffix " ?x " is not found" crlf)

      (retract ?fact1)

      (retract ?fact2))

 

If I assert the following:

(assert (a “xxx”))

 

I get the result I am looking for if I type this in using JessWin.  No problem there.  However, I have a .clp file that is being used from a Java program.  When I enter the above code in that .clp file, this fails to run.  I was told this is because there is a ‘reset’ when the clp file is invoked from the java code.

 

So I am trying to do something like this:

 

(bind $?grocery-list (create$ eggs bread milk)
 
(defrule check-suffix
        ?fact1 <- (a ?x)
        (a ?x)
        (not ($?suffix $?before ?x $?after))
        =>
        (printout t "Suffix " ?x " is not found" crlf)
        (retract ?fact1))
 
Of course, this fails.  Any ideas would be greatly appreciated.  I have been trying hard to understand this, but I must be missing something.
 
Thanks,
Joe
  




Reply via email to