I'm looking for help writing a rule that can match facts by slot value.
For example, given:
(deftemplate automobile
"A specific car."
(slot make)
(slot model)
(slot year (type INTEGER))
(slot color (default white)))
(assert (automobile (make Chrysler) (model LeBaron) (year 1997)))
(assert (automobile (make Chrysler) (model LeBaron) (year 1998)))
(assert (automobile (make Chrysler) (model SomethingElse) (year 1998)))
how would I find the two automobiles that have the same model but
different years?
This rule almost does what I want:
(defrule find-different-years
(automobile (model ?model-1) (year ?year-1))
(automobile (model ?model-2) (year ?year-2))
(test (eq ?model-1 ?model-2))
(test (not (eq ?year-1 ?year-2)))
=>
(printout t "model-1=" ?model-1
", year-1=" ?year-1
", model-2=" ?model-2
", year-2=" ?year-2
crlf))
The output of running this rule with those facts is:
model-1=LeBaron, year-1=1997, model-2=LeBaron, year-2=1998
model-1=LeBaron, year-1=1998, model-2=LeBaron, year-2=1997
What I really want is output like this:
model-1=LeBaron, year-1=1997, model-2=LeBaron, year-2=1998
from a rule looks for a second automobile, the model of which is equal
to ?model-1, with no duplicate results. What's the best way to write a
rule to do that?
Thanks,
--
Richard Kasperowski
Tel: 617-576-1552, Fax: 617-576-2441
mailto:[EMAIL PROTECTED]
http://www.altisimo.com/
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------
- Re: JESS: How to match slot values in LHS? Richard Kasperowski
- Re: JESS: How to match slot values in LHS? ejfried
- Re: JESS: How to match slot values in LHS? Richard Kasperowski
