MathGroup Archive 2008

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

Search the Archive

Re: Identical elements


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