MathGroup Archive 2008

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

Search the Archive

Re: Identical elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88410] Re: [mg88374] Identical elements
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 5 May 2008 06:09:45 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

ident[x_List] := Length[Union[x]] == 1;

n = 100000;

ident /@ RandomInteger[{0, 1}, {n, 3}];

Count[%, True]/n // N

0.25012


Bob Hanlon

---- 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: Re: Identical elements
  • 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