MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Intersection @ Complement

I see nothing whatsoever "crazy" about this behavior.  Perhaps not what 
YOU expected, but definitely not "crazy"!

There is no built-in set type of object in Mathematica.  But 
Intersection and Complement are set operations, not list operations.  So 
Mathematica gives exactly what I would expect when I intesect or 
complement the SETS of elements in the given lists.  And in all the 
cases shown, the result is a sorted list representing the corresponding set.

Zak Seidov wrote:
> Some crazy thing Mmca does with
> Intersection/Complement:
> s1={1,2,5,7,4,4,1};s2={1,6,3,5,7,7,1,6};
> Intersection[s1,s2]
> {1,5,7} (* not {1,1,5,7} ?!*)
> Complement[s1,s2]
> {2,4} (* not {2,4,4} ?!*)
> Complement[s2,s1]
> {3,6} (* not {3,6,6,7} ?!*)
> Interestingly, in both cases Mmca Help
> says that the result is SORTED list,
> while actually it's UNION not SORT that works?!
> And note that in the last case 7 is absent at all ?!
> what d'u think about this? thanks a lot, zak

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: Did something change?
  • Next by Date: Re: New Line/CR
  • Previous by thread: Intersection @ Complement
  • Next by thread: Re: Intersection @ Complement