MathGroup Archive 2008

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

Search the Archive

Re: Identical elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88430] Re: [mg88374] Identical elements
  • From: "Adriano Pascoletti" <adriano.pascoletti at gmail.com>
  • Date: Mon, 5 May 2008 06:13:21 -0400 (EDT)
  • References: <200805031017.GAA04030@smc.vnet.net>

Something like this?

In[1]:= MatchQ[{1, 2, 1}, {(x_) ...}]
Out[1]= False
In[2]:= MatchQ[{1, 1, 1}, {(x_) ...}]
Out[2]= True

or, less elegant (IMO)


In[3]:= Length[Union[{1, 2, 1}]] === 1
Out[3]= False
In[4]:= Length[Union[{1, 1, 1}]] === 1
Out[4]= True


Adriano Pascoletti

On Sat, May 3, 2008 at 12:17 PM, KFUPM <hussain.alqahtani at gmail.com> wrote:

> Dear All
>
> I have a list  and i need to test whether all the elements in the list
> are identical or no. What is the efficient way to do that? The output
> should be true if all elements are the same and False otherwise. One
> line command is preferred if possible.
>
> Your help is highly appreciated.
>
> Regards,
>
> HMQ
>
>


  • Prev by Date: 32 or 64 bit front-end on 64-bit Mac
  • Next by Date: Re: can't translate 3D model to 0,0,0
  • Previous by thread: Re: Identical elements
  • Next by thread: Re: Identical elements