|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
JESS: A rule that must match exactly 3 factsHi,
I'm starting with JESS and stumbled on a problem.
The following rule is supposed to activate when a person have exactly 3 objects. (there is exactly 3 facts "person-have-object"):
(defrule person-have-3-objects
(person-have-object ?person ?object1)
(person-have-object ?person ?object2) (person-have-object ?person ?object3) =>
(printout t ?object1 ?object2 ?object3))
In the LHS, I want to express the fact that person-have-object is found exactly 3 times for a unique person in the facts database. And I'd like to have a reference to each object for operation in the RHS.
I thought that my LHS was correct but it matches when there is only 1 fact (person-have-object myself computer). It will prints "computer computer computer".
How can I explicitly state that I want ?object1, ?object2 and ?object3 to be different?
Thank you, -- Jean-Francois Lassonde |
|
|
Re: JESS: A rule that must match exactly 3 factsIf you want object1, object2, and object3 to be different, then you
have to say so: (defrule person-have-3-objects (person-have-object ?person ?object1) (person-have-object ?person ?object2&~?object1) (person-have-object ?person ?object3&~?object2&~?object1) => (printout t ?object1 ?object2 ?object3)) On May 12, 2008, at 1:25 PM, Jean-Francois Lassonde wrote: > Hi, > > I'm starting with JESS and stumbled on a problem. > > The following rule is supposed to activate when a person have > exactly 3 objects. (there is exactly 3 facts "person-have-object"): > > (defrule person-have-3-objects > (person-have-object ?person ?object1) > (person-have-object ?person ?object2) > (person-have-object ?person ?object3) > => > (printout t ?object1 ?object2 ?object3)) > > In the LHS, I want to express the fact that person-have-object is > found exactly 3 times for a unique person in the facts database. And > I'd like to have a reference to each object for operation in the RHS. > > I thought that my LHS was correct but it matches when there is only > 1 fact (person-have-object myself computer). It will prints > "computer computer computer". > > How can I explicitly state that I want ?object1, ?object2 and ? > object3 to be different? > > Thank you, > > -- > Jean-Francois Lassonde --------------------------------------------------------- Ernest Friedman-Hill Informatics & Decision Sciences Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 PO Box 969, MS 9012 ejfried@... Livermore, CA 94550 http://www.jessrules.com -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users you@...' in the BODY of a message to majordomo@..., NOT to the list (use your own address!) List problems? Notify owner-jess-users@.... -------------------------------------------------------------------- |
| Free Forum Powered by Nabble | Forum Help |