Yes, I had noticed that.
Thank you all.
By the way, is it heavy to have such a test in a rule's LHS?
Let me be more specific. I am trying to make a kind of "refraction"
across multiple rules. The point is to prevent two rules from firing on
the same facts. For this I use a special ordered fact "rule-fired-on"
that contains a list of fact references.
In the LHS I check to see if a rule has fired before with the facts used
to activate it:
(defrule r1
?b1 <- (some-fact)
?b2 <- (some-other-fact)
(not (rule-fired-on $?b-list&:(equal-lists? ?b-list (list ?b1 ?b2))))
=>
(assert (rule-fired-on ?b1 ?b2))
(printout t "r1 fired on " ?b1 ?b2 crlf) )
Is this computationally expensive?
Thanks,
Henrique
Wolfgang Laun wrote:
Given the precondition (as Henrique wrote) that the lists are sets you
don't have to consider the general case.
-W
Szymon Klarman wrote:
Yes but this function won't do the job in general. Consider:
list1 = (1 1 2),
list2 = (2 2 3),
(union$ list1 list2) = (1 2 3)
Better to check whether intersection of the two lists have the same
length
as their union.
all best,
Szymon
----- Original Message -----
From: "Wolfgang Laun" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, February 13, 2008 3:16 PM
Subject: Re: JESS: Checking list equality
You can apply (=) to more than 2 arguments.
(= (length$ ?list1) (length$ ?list2) (length$ (union$ ?list1 ?list2)))
kr
Wolfgang
Henrique Lopes Cardoso wrote:
Hi,
I was trying to test equality for lists seen as sets (elements with
any
order).
Is there any direct function, or any solution simpler than this:
(bind ?list1 (list 1 2 3))
(bind ?list2 (list 3 2 1))
(and (= (length$ ?list1) (length$ ?list2)) (= (length$ (union$ ?list1
?list2)) (length$ ?list1)))
Thanks.
Henrique
--------------------------------------------------------------------
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]
--------------------------------------------------------------------