[Date Index]
[Thread Index]
[Author Index]
Re: Re: Re: how to delete duplicate items in the same list
*To*: mathgroup at smc.vnet.net
*Subject*: [mg45657] Re: [mg45592] Re: [mg45576] Re: how to delete duplicate items in the same list
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Fri, 16 Jan 2004 19:58:41 -0500 (EST)
*References*: <bto1uf$2ka$1@smc.vnet.net> <bu0cjl$ah9$1@smc.vnet.net> <200401140626.BAA19761@smc.vnet.net> <200401161105.GAA10620@smc.vnet.net> <6EF6A163-4835-11D8-BA03-0003938BF55C@jeol.com>
*Sender*: owner-wri-mathgroup at wolfram.com
On 16 Jan 2004, at 15:05, Sseziwa Mukasa,,(978) 536-2359 wrote:
>
> 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].
>
The suggestion that Union[a] might be taken to mean something like
Union[a,a] or Union[a,{}] (which was not due to me) was presumably
meant to justify the name of the function. Personally, however, I think
it is incorrect to think that Mathematica in this way "implements" the
mathematical notion of set. In general the philosophy of Mathematica is
to implement (in the Kernel) relatively few specific mathematical
concepts but instead provide the user with tools which make
implementing of such concepts easy. Thus sets can be implemented in
Mathematica in various ways, one being in terms of hash functions, as
described above, another as ordered sets and there are in fact several
other ways that a user can easily implement. The functions Union,
Intersection and Complement are certainly inspired by the set theoretic
notions and can be used in implementing them, but they are also useful
in programming contexts where we one does not care if one is dealing
with "sets" in any "rigorous" sense. In fact the fact that the
following works:
Union[L[a],L[b,c,d]]
L[a,b,c,d]
illustrates that Union and the other functions are intended to be used
beyond the most obvious mathematical context.
From the programming point of view it is natural to extend the meaning
of these functions to the case of a single argument (Union actually
works with 0 arguments too, the other two require at least 1) and there
is no real need to provide a "mathematically sophisticated argument".
But in any case, the usual set theoretic definition of union certainly
applies to all the cases (including one and zero arguments): "The union
of any number of sets consists of the elements contained in at least
one of them". Still, the relation with set theory should be seen as
inspiration and motivation, but no more than that. The same is true of
other Mathematica notions that are inspired by mathematical concepts
but are not necessarily their strict "implementations".
Andrzej Kozlowski
Chiba, Japan
http://www.mimuw.edu.pl/~akoz/
Prev by Date:
**Re: Mathematica software for pde**
Next by Date:
**Re: Re: hyperlink to pdf files**
Previous by thread:
**Re: Re: Re: how to delete duplicate items in the same list**
Next by thread:
**Re: how to delete duplicate items in the same list**
| |