Thanks. Of course the member$ thing was just a provocation... ;)
Just wondering if there was an efficient way in both senses (execution
and typing)...
So, while your solution is the most efficient one, Jess 7.1 will give it
for free from mine.

H.


Ernest Friedman-Hill wrote:
On Feb 15, 2008, at 9:28 AM, Henrique Lopes Cardoso wrote:

(defrule
    ?b1 <- (t1 (s ?s1))
    ?b2 <- (t2 (s ?s2))
    (or (test (eq ?s1 x)) (test (eq ?s2 x)))
    =>
    ...)

This example simplifies the general case. I may have any number of
bindings, and the common slot 's' is checked to see if at least one of
the bound facts has a certain x value. Is there a more efficient
way of
doing this? E.g. (member$ x (list ?b1 ?b2 ...)) ?


Efficient in terms of typing these out, or in terms of execution?
We're actually working on optimizing these kinds of things in the
network; by the final release of Jess 7.1, the above should actually
be equivalent to something like

(defrule
    (or (and ?b1 <- (t1 (s ?s1&x))
             ?b2 <- (t2 (s ?s2)))
        (and ?b1 <- (t1 (s ?s1))
             ?b2 <- (t2 (s ?s2&x))))
    ==>

which is extremely efficient. The above is the best way to write this
right now, but hopefully the two will soon be equivalent.





---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550                 http://www.jessrules.com

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



--
----- - - - - -  -  -  -  -  -   -   -
Henrique Lopes Cardoso
DEI/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
----- - - - - -  -  -  -  -  -   -   -

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