I want to define two subscripted functions Subscript[f,1]
and Subscript[f,2]
. To keep the assignments local, I would like to associate the definitions with f
if possible. My current solution is to write the following.
f/:Subscript[f,1]:=Function[x,g[x]]
f/:Subscript[f,2]:=Function[x,h[x]]
The resulting definition is stored as an UpValue for f
, which is acceptable for me. Is it possible to construct a similar definition using pattern matching? I am looking for an analog to the following pair of definitions.
f[x_]:=g[x] (*definition 1*)
f:=Function[x,g[x]] (*definition 2*)
In other words, I am currently using a definition akin to definition 2 above for my subscripted functions. Is it possible to write a definition analogous to definition 1 above?
f /: Subscript[f[x_], 1] := g[x]
? Seems quite straight forward, so if that's your question you almost answered it yourself. $\endgroup$Subscript[f,1][x_]
which would be too deep for anUpValue
$\endgroup$