0
$\begingroup$

Let's suppose I have a code like this:

ClearAll["Global`*"]
a = 2;
b = 3;
Sab=*lots of calculations on a and b*
Save["S" <> ToString[a] <> "" <> ToString[b] <> ".m",{Sab}]

This codes construct the set Sab for a=2 and b=3 and saves a file called "S23.m". Now... I have another code like this:

ClearAll["Global`*"]
a = 2;
b = 3;
Sab=*lots of calculations on a and b*
* . . . Lots of calculations on Sab . . . *
* . . . Some results . . . *

I would like to use Get in the second code to use the sets Sab that were previously calculated, so I wouldn't need to calculate them again, but these files depend on the inputs a and b. I tried, for example,

<< "S" <> ToString[a] <> "" <> ToString[a] <> "half.m"

but it doesn't work. How can I do it?

$\endgroup$
3
  • $\begingroup$ Just Get[ "S" <> ToString[a] <> "" <> ToString[a] <> "half.m"], see linked topic for explanation and let me know if you disagree with closing $\endgroup$
    – Kuba
    May 26, 2018 at 20:31
  • $\begingroup$ @Kuba I think the point is that << reads just names, while Got can read a stream [this was taken from documentation]. Anyway... Should I delete this question? $\endgroup$
    – Filburt
    May 26, 2018 at 21:58
  • $\begingroup$ Wording matters so I will just say the point is explained in the linked topic. No, it can stay as a roadsign. $\endgroup$
    – Kuba
    May 26, 2018 at 22:13

0

Browse other questions tagged or ask your own question.