We know:
Map[Head, {a, a^2, a^3}]
(* {Symbol, Power, Power} *)
and Map[Head, {2, 2^2, 2^3}]
all of them will be known as Integers
.
But how can we get the result of
Map[Head, {2, 2^2, 2^3}]`
{Integer, Power, Power}
I mean how Mathematica recognize a value is a power of two others?
#[[1, 0]] & /@ {Hold[2], Hold[2^2], Hold[2^3]}
givesInteger, Power, Power
$\endgroup$2^2
evaluates and becomes4
, it is not aPower
. $\endgroup$SetAttributes[f, HoldAll]; f[x_]:=Head@Unevaluated@x; Map[f, Unevaluated@{2, 2^2, 2^3}]
$\endgroup$PrimePowerQ[]
. $\endgroup$