I have the following code:
Subscript[f, i_][x_] := Block[{a},
Subscript[a, i] = 3 x;
Subscript[a, 1]
]
If I evaluate for example Subscript[f,1][2]
, thenit evaluates to 6
. After that asking what Subscript[a,1]
is also gives me six. However, I want a
to be a local variable.
My question: how can I define a local variable while using indices...?
Note: the original post mentioned that evaluating Subscript[f,1][2] = 6
would lead to the described behaviour, which just isn't true. A reasonable guess is that this was ment to mean that Subscript[f,1][2]
was to be evaluated and it would evaluate to 6
(which it does). After that Subscript[a,1]
will evaluate to 6
as reported.