I think Foertsch, Eric wrote:
>
> I see said the blind man. With your note, and a bit more
> experimentation, I see that the Iterator returned by defquery returns a
> list of jess.Fact, not fact-ids.
Actually, it's a list of jess.Token; calling fact() on a Token gets you a
jess.Fact object.
>
> (defrule test
> ?fact-id <- (illness (name Flu) ) ; this gives you a fact-id
Note that ?fact-is actually bound to the jess.Fact object itself.
>
> (deffunction get-symptom-list ()
> "Run query to get all symptoms concatenated to one list"
> (printout t "start of get-symptom-list" crlf)
> (bind ?it (run-query get-all-symptoms)) ; ?it contains
> java.util.Iterator
> (while (?it hasNext) ; use Iterator.hasNext() method to see if
> more results
> (bind ?token (call ?it next)) ; call Iterator.next() to get
> jess.Token (which
> ; contains a jess.Fact
> (bind ?jess-fact (?token fact 1)) ; so get the jess.Fact, NOT the
> fact-id
> (bind ?fact-id (fact-id (?jess-fact getFactId))) ; now get the
> fact-id
This step is unnecessary; fact-id has to do a slow lookup. But I
understand why you're doing it; it's pretty esoteric and I won't
explain it now except to say instead of this last line, do this
instead:
(bind ?fact-id (?jess-fact getIcon))
It will have the same effect and be much more efficient.
NOTE: The next major release of Jess is going to include a completely
revamped, much less obscure way of invoking queries (although the old
way will still be in there for compatibility.)
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems 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]
--------------------------------------------------------------------