MathGroup Archive 2011

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

Search the Archive

Re: Reduce a vector eliminating equal components

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117051] Re: Reduce a vector eliminating equal components
  • From: Peter <petsie63 at googlemail.com>
  • Date: Tue, 8 Mar 2011 05:38:46 -0500 (EST)
  • References: <il2deu$67r$1@smc.vnet.net>

On 7 Mrz., 11:53, Antonio Mezzacapo <ant.mezzac... at gmail.com> wrote:
> Hello,
>
> I would to know if there is a simple way to obtain this result: I have a
> vector of size n who contains a certain number of same object. I want it to
> be reduced to a smaller vectors who doesn't contains equal objects.
>
> Thank you
> Antonio Mezzacapo

Hi,

Union[] returns a sorted result. If you don't want this, use
DeleteDuplicates:

In[1]:= vec=RandomInteger[5,10]
Out[1]= {1,2,0,1,5,5,4,1,5,1}

In[2]:= DeleteDuplicates[vec]
Out[2]= {1,2,0,5,4}

Peter


  • Prev by Date: Older documentation
  • Next by Date: Notebook interface and Wolfram-Alpha
  • Previous by thread: Re: Reduce a vector eliminating equal components
  • Next by thread: Re: Reduce a vector eliminating equal components