jQuery in Action, 2nd edition*
The moose likes Other Java Products and Servers and the fly likes A difficult Jess rule Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "A difficult Jess rule" Watch "A difficult Jess rule" New topic
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: 24183
    
  34

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A difficult Jess rule