I think Mehta, Chirag (IT) wrote:
> Hello,
>  
> I have a few more questions. Hopefully, these aren't as simple as my
> previous ones.
>  
> Firstly, is there a simple way of checking how many facts have a
> particular slot value??

As you said, a query with count-query-results is one good way. The
upcoming Jess 7 has "accumulate" which would allow you to do the
counting on the LHS of a rule and have the RHS of the rule get the
count and be able to act on it.

>  
> Also, I need to check whether a particular slot value, of any already
> activated fact, is less than the corresponding slot value of the current
> fact? What would be the best way of implementing this? The slot value
> that needs to be checked is calculated by another rule. I think backward
> chaining maybe an option here but I'm sure how I would use it. 


In general, if you're thinking procedurally like this, then the
answer is usually to use a query. But a better answer is not to think
procedurally. If you want to do something with the fact that has the
lowest value in a given slot, then write a rule to match it and do
that something:

(defrule process-lowest-value
  (some-fact (some-slot ?v1))
  (not (some-fact (some-slot ?v2&:(< ?v2 ?v1))))
  =>
  (printout t ?v " is the lowest value." crlf))

The second pattern says "there's does not exist a some-fact where
some-slot contains a smaller value than ?v1."


---------------------------------------------------------
Ernest Friedman-Hill  
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to