Well, I'm not sure where you're going with the templates exactly, but
note that there are two functions, union$ and intersection$, that will
do the work. Have a look in the README for documentation on these
functions.
Presumably a set has only one name, so most of the multislots below
should be plain slots; only set.members should be a multislot. In that
case, a compute-union rule that created a new set to hold the result
might look like
(defrule compute-union
?u1 <- (union (set-1-name ?s1) (set-2-name ?s2))
(set (name ?s1) (members $?m1))
(set (name ?s2) (members $?m2))
=>
;; I'm assuming this is a command so we want to retract it now
(retract ?u1)
(assert (set (name (sym-cat union-of- ?s1 -and- ?s2))
(members (union$ $?m1 $?m2)))))
I think C P Lee wrote:
>
>
> I have a question about finding the intersection and union of two
> sets with set template (deftemplate set
> (multislot name)
> (multislot members))
>
> union template (deftemplate union
> (multislot set-1-name)
> (multislot set-2-name))
>
> intersection template (deftemplate intersection
> (multislot set-1-name)
> (multislot set-2-name))
>
> How to define rules to compute the intersection and union of two sets?
>
>
> Lee
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
>
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9214 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------