I want to substitute integers in a list with theirs square, I tried these
Cases[{{1, 2, 3}, a, {4, 5}}, t__ /; Element[t, Integers] :> t^2]
(*{{1, 4, 9}, {16, 25}}*)
Cases[{{1, 2, 3}, a, {4, 5}}, t__ /; IntegerQ[t] :> t^2]
(*{}*)
Why the first code works and the second doesn't?
What is the difference between Element
and IntegerQ
?