I'm quite sure this is an easy question but Im missing something.
I wish to define a function whose action depends on whether the input is a single matrix or a multiplication of two, For example:
I would want to do get:
f[x*y] (* x+y *) f[x] (* x *)
Even though this example isn't interesting it is enough to demonstrate my issue.
f[x_] := If[Head[Unevaluated[x]] == Times, (Unevaluated[x][]) + (Unevaluated[x][]) , x]
Indeed I get:
f[x*y]==x+y (* True*)
But I get:
f[x] (* If[Symbol == Times, Unevaluated[x][] + Unevaluated[x][], x] *) f (* If[Integer == Times, Unevaluated[] + Unevaluated[], 7] *)
Any explanation or an explanation of a better way to achieve my goal are welcome