| Author |
A difficult Jess rule
|
Hope Zhu
Ranch Hand
Joined: May 11, 2004
Posts: 32
|
|
Hi, I am working on writing a rule to figure out which shadow fact in a group has the latest timestamp. Then use the found out in another rule. All shadow facts are the same java object and the size of the group is changable. If there are only two in the group I know how to achieve the goal, but more than two in a group I could not figure out how to do it. Can someone please help!!! Thanks in advance
|
 |
Hope Zhu
Ranch Hand
Joined: May 11, 2004
Posts: 32
|
|
Forgot one more thing. I know if I always retract the shadow fact which has the older timestamp then I will only have the latest left. But I may need the old facts to stay in for other rules. So the question should be without retracting any facts how to find out which one is the latest. Thanks again.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24041
|
|
The general way to write this is (pseudocode) A rule like this will fire just once, for the very latest fact. So, imagine there's a template like (deftemplate object (slot timestamp (type LONG))) then the rule might look like
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: A difficult Jess rule
|
|
|