I have three variables like this,
r1 = 4;
r2 = 3;
r3 = 1;
and I want to insert them into a function use them in a function definition like so:
f[n_] := r[n] + r[n-1]
So I need to have a function that just duplicates the variable, something like:
r[1] = r1 = 4;
r[2] = r2 = 3;
r[3] = r3 = 1;
Firstly, I thought of doing
r[n_] := r[n]
but that doesn't make much sense.
I was wondering if there is some nice way to do this?
r[n_] := Symbol["r" <> ToString[n]]
$\endgroup$