I think you didn't appreciate what Wolfgang is saying. A list -- and a
multislot is indeed a list -- is intrinsically ordered. The order in
which the items appear matters. If you have a collection in which the
order does not matter, then a list isn't appropriate to store it; it's
a set, not a list. To implement a set in Jess, you can use a
java.util.Set implementation in a regular slot. By doing this, all the
difficulties you describe just go away.
On Feb 24, 2009, at 8:40 AM, Joao Antunes Mourao wrote:
Thanks Wolfgang,
but i had solve already my problem.
My question was only about the duplication of /"nots/", that one has
to
write in order to not duplicate facts. I handle the situation
creating a
function that check if a list contains a specific element or set of
elements, without mind to the sequence.
Like for example you have a fact:
/(black-cars (id A B))/
and somewhere you have a rule that takes two cars, but then you
enforce
that the cars cannot be black, like:
/(defrule ...
(car (id ?id1))
(car (id ?id2))
(not (black-black-cars (id ?id1 ?id2))/
..
now, if the matching variables get: ?id1=B, and ?id2=A, then the rule
will be fired, and the only way to avoid this is having another "/
not/"
swaping the ids. This kind of solution becomes really confuse, if you
have a list of 3 or more elements. So, i implement a function that
check
if a list contains a set of elements. My question in the mailing list
was only wondering if there was a more clean way to make this. It
seems not.
Regards,
Joao
----------
unclassified
On 24-02-2009 09:39, Wolfgang Laun wrote:
Perhaps the discussion in
http://www.jessrules.com/jesswiki/view?PropertySet is useful for you.
-W
On Mon, Feb 23, 2009 at 6:11 PM, Wolfgang Laun
<[email protected] <mailto:[email protected]>> wrote:
On Mon, Feb 23, 2009 at 5:22 PM, Joao Antunes Mourao
<[email protected]
<mailto:[email protected]>> wrote:
Hello,
/(defrule get-black-cars
(car (id ?id1) (color "black"))
(car (id ?id2 &:(~= ?id1 ?id2)) (color "black"))
(and (not (black-cars (car-id ?id1 ?id2)) (not (black-cars
(car-id ?id2 ?id1)))
=>
(assert (black-cars (car-id ?id1 ?id2)))/
The second CE is better written as
(car (id ?id2 & ~?id1)) (color "black"))
My question is: There is a matching way of avoid this
comparison? The only thing i want to know is which are the
black cars, not the order.
You are talking of sets (in the mathematical sense). For the
general case you might consider using a java.util.Set as a
(non-multi-)slot value.
-W
------------------------------------------------------------------------------------------------------------
Disclaimer:
If you are not the intended recipient of this email, please notify
the sender and delete it.
Any unauthorized copying, disclosure or distribution of this email
or its attachment(s) is forbidden.
Thales Nederland BV will not accept liability for any damage caused
by this email or its attachment(s).
Thales Nederland BV is seated in Hengelo and is registered at the
Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------
<joao.mourao.vcf>
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs
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].
--------------------------------------------------------------------