MathGroup Archive 2004

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

Search the Archive

Re: Re: Re: how to delete duplicate items in the same list

On Jan 16, 2004, at 6:05 AM, Andrzej Kozlowski wrote:

> The possibility of using Union for testing the presence or absence  of
> duplicates is a side effect rather than the main purpose of Union.

Rather than arguing the behavior of Union[a] as being a side effect or 
a short hand for Union[a,a] why not consider it a shorthand for 
Union[a,{}] in which case there is no confusion.  I suppose there is no 
confusion in the case of Union[a,a] but it's hard to imagine why 
someone would care about that expression in the first place.  I am not 
mathematically sophisticated though, so forgive me if I don't 
understand the import of Union[a,a].

There is still the issue of the representation of a set in Mathematica 
especially due to the unfortunate choice of {} as list delimiters.  
 From a programmer's point of view the mathematical object set is 
probably best represented by a hash function which hashes all possible 
patterns of bits, since ultimately a set can contain anything a 
computer can represent, and a  membership function which can tell 
whether the hash value for a specific bit pattern is occupied for a 
specific set.  That's unwieldy in practice, and a sorted list is 
probably sufficient, however since a hash only has the concept of 
membership or nonmembership there is no idea of repetition of elements. 
  Thus the representation of sets as a list of unique elements 
representing the members, sorting just helps with efficiency.  It's not 
a rigorous explanation, I'd be happy to hear what a proper 
mathematician/computer scientist has to say on the subject, but I think 
it explains the behavior of Union[a].



  • Prev by Date: RE: Sort into chain
  • Next by Date: Re: Mathematica for Macintosh questions.
  • Previous by thread: Re: Re: how to delete duplicate items in the same list
  • Next by thread: Re: Re: Re: how to delete duplicate items in the same list