I am sure this has been asked before in a way or another. I need to Save
or DumpSave
some symbols that contain the result of some processing.
Currently my code has a low level function that does the dirty work, and a high level one that is a handy proxy to call the low level one.
Here is how my code schematically works:
LowLevelFunction[ba_] := Module[{res},
Table[res[elem] =
If[ToString[ba] == "yes", X, 2 X], {elem, {one, two}}];
res]
HighLevelFunction[a_] := Module[{res}, res = LowLevelFunction[a]; res]
Then I use these functions as:
Processed[yes] = HighLevelFunction[yes]
Processed[maybe] = HighLevelFunction[maybe]
At this point ?Processed
returns Processed[maybe]=res$2748
and Processed[yes]=res$2745
. I am happy with this so far because I can evaluate in the current notebook and get the answer that I want
Processed[yes][one]
Processed[maybe][two]
Out[270]= X
Out[271]= 2 X
Furthermore when I do Save["~/fileprocessed.mx", Processed]
I get a mx file that contains a reference to res$2748
and res$2745
and the actual symbols res$2748
and res$2745
. Therefore I can do Get["~/fileprocessed.mx"]
on a new notebook and a new kernel and
Processed[yes][one]
Processed[maybe][two]
will give me the right output.
Now my question is if there is a better way of handling this. For instance a way that avoid having to use Temporary objects, that, for instance, would not be saved if I use DumpSave
instead of Save
.