Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2008

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

Search the Archive

Re: Identical elements

  • To: mathgroup at
  • Subject: [mg88436] Re: Identical elements
  • From: "Dana DeLouis" <dana.del at>
  • Date: Mon, 5 May 2008 06:14:27 -0400 (EDT)

> 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.


Hi.  Here's one way.  I assume a list with 1 element returns False.


AllEqualQ[v_List] := 

 If[Length[v] == 1, False, Equal[1, KroneckerDelta @@ v]]



HTH :>)

Dana DeLouis

Mathematica 6.01 (Windows Vista)

  • Prev by Date: Re: Fit data with range
  • Next by Date: Re: Identical elements
  • Previous by thread: Re: Identical elements
  • Next by thread: Re: Identical elements