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? 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 :)
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]
---------------------------------------------------------------------