I used to do a lot of programming in R and recently switched to Mathematica. One thing that bothers me is that I haven't found a way to save variables, their values and definition!
Let's look at an example:
idx = Partition[RandomSample[Range[20], 20], 3];
Table[Subscript[vars, idx[[i]]] = Total[idx[[i]]], {i, 1,
Length[idx]}];
Subscript[vars,{9,15,8}]
(*32*)
Is there a way to save the variable names as well as the corresponding values. And how would I read them into a new file? So that in a new file I can access with Subscript[vars,{9,15,8}] the value.
I tried it with Table[...]>>values.mx and read it in with values=<<values.mx but that only gives me the values, whereas I also need the definitions. I also tried:
DumpSave["values.mx",
Table[Subscript[vars, idx[[i]]] = Total[idx[[i]]], {i, 1, Length[idx]}]]
but got an error
DumpSave::bsnosym: "Table[..] is not defined as a symbol or a context"
DumpSave[ ]not work properly for you? – bill s Mar 15 '13 at 08:22DumpSave[]. Can you help him? – Dr. belisarius Mar 15 '13 at 08:50DumpSave["values.mx", Table[Subscript[vars, idx[[i]]] = Total[idx[[i]]], {i, 1, Length[idx]}]]but got an error(*DumpSave::bsnosym: "Table[..] is not defined as a symbol or a context"*)– rainer Mar 15 '13 at 09:39Subscript[vars,i]is not the easy way to do indexing in Mathematica. It is more of a typesetting convenience, that is, for display. The easy thing to do is to havevarsbe a list, and to index into that list. This is the way I answered the question below. – bill s Mar 15 '13 at 10:00DumpSave. – rainer Mar 15 '13 at 11:06vars, correct? – Mr.Wizard Mar 15 '13 at 11:16