MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Returning a local array

  • To: mathgroup at
  • Subject: [mg84197] Re: Returning a local array
  • From: Jens-Peer Kuska <kuska at>
  • Date: Thu, 13 Dec 2007 05:50:34 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <fjqj9l$6l9$>
  • Reply-to: kuska at


but using rules for a long list of parameters
is the way that Mathematica use in all of it's
If you would like to reference a global variable,
you should pass it to the function with a Hold* attribute,




Art wrote:
> 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.

  • Prev by Date: Re: Silly question about Contexts
  • Next by Date: Re: Arrows on curves
  • Previous by thread: Returning a local array
  • Next by thread: Re: Returning a local array