Skip to main content
1 of 4
rm -rf
  • 89.3k
  • 21
  • 297
  • 479

I think a solution based on pattern matching will be much faster than ones based on Element (which is more mathematical in usage) or pattern tests or anythign else that forces evaluation, since we can bypass the main evaluator.

ClearAll@realQ
SetAttributes[realQ, Listable]
realQ[_Real | _Integer | _Rational] := True
realQ[_] := False

realQ[{"text", 0, 3.0, 1/2, I}]
(* {False, True, True, True, False} *)
rm -rf
  • 89.3k
  • 21
  • 297
  • 479