I think Ricardo Manuel Oliveira wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
>
> This raises some questions :)
> What does the (OBJECT ?o) part do, exactly? is it some kind of reference
> to the object returned by the timeOfDay call?
See manual section 2.7.4. It's the "myClass" object.
I'm asking this, because
> there are other things I wish to compare besides the time, and I'm not
> sure this will work.. I should have something like:
>
> (myClass (name ?name) (email ?email) (timeOfDay ?time))
>
> I tried finding something in the docs about this, but I couldn't...
> furthermore, how will I iterate over the objects firing rules? I'm not
> quite getting this part :)
You don't iterate over the objects and fire the rules. You just
definstance all the Objects, and call (run), and Jess fires the rules
for each object that applies. If this doesn't work for you, then don't
use rules; use the defquery instead.
>
> I'm sorry if this sound silly, but I'm totally knew at this kind of
> programming.. I'm more used to objects and references :)
>
> On Wednesday 11 July 2001 13:27, friedman_hill ernest j wrote:
> > You could use either a defrule or a defquery to do it; the difference
> > depends on the context in which you want to use it. If you need to
> > write procedural code that iterates over all the matching objects,
> > then use a defquery. If you want to have a rule fire for each match,
> > use a defrule. Both the query and rule below can find all pairs of
> > objects that have the same time. We assume the hashCode values are
> > distinct and use them to order the results, otherwise you'll get both
> > (a,b) and (b,a) as separate matches.
> >
> >
> > (defquery query
> > (declare (variables))
> > (myClass (timeOfDay ?t) (OBJECT ?o))
> > (myClass (timeOfDay ?t) (OBJECT ?p&~?o))
> > (test (< (call ?o hashCode) (call ?p hashCode))))
> >
> > (defrule rule
> > (myClass (timeOfDay ?t) (OBJECT ?o))
> > (myClass (timeOfDay ?t) (OBJECT ?p&~?o))
> > (test (< (call ?o hashCode) (call ?p hashCode)))
> > =>
> > (printout t ?p " has the same time as " ?o crlf))
> >
> >
>
> --
> Cheers,
>
> -- Ricardo Manuel Oliveira
> -- FCT - University of Coimbra, Portugal
>
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
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]
---------------------------------------------------------------------