As others have said, this is a bad idea. However, if you only care about the appearance of f
, then you could so something like this:
f // ClearAll;
intF = RowBox[ { RowBox[ { "f", "[", #1, "]" } ], "[", #2, "]" } ] &;
dspF = RowBox[ { "f", #1, "[", #2, "]" } ] &;
f /: MakeBoxes[ f[ n_ ][ x_ ], form_ ] :=
With[ { ns = ToString @ n, xs = ToString @ x, if = intF, df = dspF },
TemplateBox[ { ns, xs }, "f",
InterpretationFunction :> if,
DisplayFunction :> df
]
];
All this really does is change the appearance of f[n][x]
. So now you get results that look like this:
However, it could get tedious to copy and paste the boxed version whenever you want your input to be displayed this way. As an alternative (which I think looks nicer too), you can use SubscriptBox
instead:
f // ClearAll;
intF = RowBox[ { "f", "[", #1, "]" } ] &;
dspF = SubscriptBox[ "f", #1 ] &;
f /: Subscript[ f, n_ ] := f @ n;
f /: MakeBoxes[ f[ n_ ], form_ ] :=
With[ { ns = ToString @ n, if = intF, df = dspF },
TemplateBox[ { ns }, "f",
InterpretationFunction :> if,
DisplayFunction :> df
]
];
fail[x]
becomingx + ail
$\endgroup$Format[f[n_][x_]] := Subscript[f, n][x];
to "prettify" the display. $\endgroup$f[1]
overf1
is thatf1
is a symbol, whilef[1]
is aDownValue
of the symbolf
. One can dof1[[3]]=c
but notf[1][[3]]=c
. +1 to the Q, I've learned about$NewSymbol
today thanks to it. $\endgroup$