Re: Identical elements
- To: mathgroup at smc.vnet.net
- Subject: [mg88436] Re: Identical elements
- From: "Dana DeLouis" <dana.del at gmail.com>
- 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)