Answer by eldo for PatternTest in Function
h = If[NumericQ[#], #^2, HoldForm[h][#]] &;h /@ {3, a}{9, h[a]}g = If[NumericQ[#], Function[x, x^2][#], HoldForm[g][#]] &;g /@ {3, a}{9, g[a]}
View ArticlePatternTest in Function
This is probably trivial and already asked but I did not find it.How to use PatternTest inside Function (g) or in pure function (h) so that it provides the same result as f?Clear[f, g, h,...
View Article