Check whether array has only constant entries?

You can Apply (@@) Equal to your list:

constantQ = Equal@@#&;

constantQ @ {0,1,0,0}
(* False *)

or

constantQ2 = Max@#==Min@# &;
constantQ3 = Variance@#==0;
constantQ4 = Length@DeleteDuplicates@# == 1 &;

See also: SameQ

constantQ5 = SameQ @@ #&

Equal @@ {1, 1., 1}
(* True *)
SameQ @@ {1, 1., 1}
(* False *)

...


Not sure why people don't like DeleteDuplicates :)

Length@DeleteDuplicates@arr > 1

for me this is faster than other methods (using V9 OS X tonight)


If[Length[Tally[arr]] == 1, IsConst = True, IsConst = False]