I'd like to check if all elements of a list are numbers. I've tried
t = {5/4, 12}
MatrixQ[t, NumberQ]
MemberQ[t, NumberQ]
And @@ Table[NumberQ[t[[i]]], {i, 1, Length[t]}]
but only the last one yields the desired result. Is there a better way to check?
VectorQ[t, NumberQ]
orAllTrue[t, NumberQ]
should do the trick - theVectorQ
version only accepts lists of numbers, while theAllTrue
version accepts any head $\endgroup$ContainsOnly[t[[All, 0]], {Rational, Integer}]
possibly with the addition ofReal
and/orComplex
$\endgroup$Table[ Im[z] == 0, {z, t} ]
$\endgroup$Reals
andNumberQ
as if they were the same when they are not, and by the fact that Irrationals like $\pi$ and $e$ are notNumberQ
. You are getting contradictory answers! Can you please edit and clarify? $\endgroup$