I have an array arr
with n
entries. Now I want to check whether
arr[[1]]==arr[[2]]&&arr[[2]]==arr[[3]]&&...arr[[n-1]]==arr[[n]]
Of course I could use a for
-loop, like
arr = {0, 1, 0, 0};
IsConst = True;
For[i = 1, i <= Length[arr], i++,
If[arr[[i]] != arr[[1]],
IsConst = False;
i = Length[arr];
];
];
Print[IsConst];
But that doesn't look too fast, so I wonder whether there is a faster way.