0

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?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Filburt
  • 578
  • 5
  • 13
  • Just Get[ "S" <> ToString[a] <> "" <> ToString[a] <> "half.m"], see linked topic for explanation and let me know if you disagree with closing – Kuba May 26 '18 at 20:31
  • @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? – Filburt May 26 '18 at 21:58
  • Wording matters so I will just say the point is explained in the linked topic. No, it can stay as a roadsign. – Kuba May 26 '18 at 22:13

0 Answers0