I would like to return a local array. The below seems like the wrong
way to do it:
f[] := Module[{h}, h["a"] = 1; h["b"] = 2; h];
g = f[];
I would like g not to be associated with the local variable h, but
equivalent to defining it as follows:
g["a"] = 1; g["b"] = 2;
Is it better to work with rules instead? It can become awkward and I
would like to avoid it.
f[] := Module[{h}, h={"a" -> 1, "b" -> 2}; h];
g = f[];
"a" /. g
The specific problem is I am reading the header for a binary file that
has 20 or so parameters describing the binary file. I thought this
would be the analog of a structure in other languages and a good way
to put these parameters in a variable.
Thanks.