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?
Answer
You can do this with the Notation Package and its Symbolize function:

The definition is not attached to Subscript, but to pseudo-Symbol f1:

Comments
Post a Comment