MathGroup Archive 2006

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

Search the Archive

Re: RE: Context headache

  • To: mathgroup at
  • Subject: [mg70972] Re: [mg70937] RE: [mg70907] Context headache
  • From: Yasvir Tesiram <yat at>
  • Date: Fri, 3 Nov 2006 01:39:20 -0500 (EST)
  • References: <>

I agree with David. You can also lump the data in as a List of Lists  
(or a huge array)

megadata = {data1, data2, data3, data4 ,data5};

To access one chunk you can use Part. To apply functions, you can  
define various functions such as f1, f2, f3, and then use Map,  
MapThread etc to operate on the various data.


On Nov 2, 2006, at 5:47 AM, David Park wrote:

> Xerxes,
> I think that Context would be a poor tool for doing this.
> Why not store your different data sets as...
> data[1] = ...
> data[2] = ...
> and then, if you are doing a lot of calculations on each set...
> With[{data=data[5]}, calculations using data]
> or
> With [{n=5}, calculations using data[n]]
> David Park
> djmp at
> From: Xerxes [mailto:Xerxes314 at]
To: mathgroup at
> Hi all,
> I'm trying to write a Mathematica analysis package in which
> various data sets are distinguished by being placed in their
> own contexts, say data1`data, data2`data, etc. This is helpful
> in that you can always hop into a context to work with each
> data set individually. Of course, at some point, that method
> becomes too much of a chore and you want to automate things.
> I'm trying to make a function that iterates over several contexts;
> it will hop into the context, execute a function on the data in
> that context, save the result as another variable in that context
> and then hop back out.
> But as described in
> 7368d0cd14
> aa8960
> (thread aptly named "Nailing jelly to a tree"), you can't do this.
> As soon as you try evaluating the iterating function, all the
> variables inside it get poisoned with the Global` context. You
> might try fixing this by using more nails on the jelly, say
> a hideous construct like
> Evaluate[Symbol[$Context<>"result"]] =
>   analyze[Evaluate[Symbol[$Context<>"data"]]];
> but since my actual functions are much more complicated than
> this simple example, any readability of the code goes right away.
> Is there any better workaround known that would allow
> iteration over multiple contexts?
> Or alternatively, since it seems like I'm trying to force contexts
> to do something they don't want to do, is there some better
> data encapsulation technique I haven't thought of yet?
> Thanks,
> Xerxes

  • Prev by Date: Re: Clarification re. Curiosity concerning transformation rules for List
  • Next by Date: Re: Context
  • Previous by thread: RE: Context headache
  • Next by thread: Re: Context headache