MathGroup Archive 2005

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

Search the Archive

Re: Unsorted Union

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61528] Re: Unsorted Union
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Fri, 21 Oct 2005 00:38:15 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 10/19/05 at 11:08 PM, klk206 at panix.com (Konstantin L Kouptsov)
wrote:

>Robert Schoefbeck wrote:

>>in the help section i found the following thing:

>>UnsortedUnion[x_] := Module[{f}, f[y_] := (f[y] = Sequence[]; y);
>>f/@x]

>>It does just what it says: UnsortedUnion[{a,c,b,d,a,b}]={a,c,b,d}

>Actually, it soes not:

>In[2]:= UnsortedUnion[{a, b, c, c, c, c, b}] 
>Out[2]:= {a,b,c}

If your comment was intended to say UnsortedUnion does something other than stated in the documentation, then you are incorrect. The example you used here happens to have the first occurance of each element in the list in order. Consequently, UnsortedUnion and Union result in exactly the same output.

But if you were to change the order of the first two elements, i.e.,

In[7]:=UnsortedUnion[{b, a, c, c, c, c, b}]
Out[7]={b, a, c}

it should be clear UnsortedUnion is performing as claimed.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: (a/b)^2 when a/b is replaced by e won't yield e^2
  • Next by Date: Re: Re: Map Thread & Inner
  • Previous by thread: Re: Unsorted Union
  • Next by thread: Re: Unsorted Union