For computing the union and intersection, duplicate elements
should not be allowed to appear in the union or intersection of the sets.
The final result for both union and intersection should be a new set fact
containing the union or intersection of the two specified sets and the
union and intersection facts should be retracted when the operations are
complete. Did the rule define below consider the duplicate elements?
I would prefer to define rules for union and intersection rather than
using the build-in function union$ and intersection$. Is it possible?


Lee

On Tue, 25 May 1999, Ernest Friedman-Hill wrote:

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


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

Reply via email to