1
$\begingroup$

If I limit the context of each notebook:

enter image description here

and use parallel computation:

ParallelTable[ToExpression["b" <> ToString[j]], {j, 1, 10}]

then after computation instead getting this:

{b1, b2, b3, b4, b5, b6, b7, b8, b9, b10}

I get this:

{Global`b1, Global`b2, Global`b3, Global`b4, Global`b5, Global`b6, Global`b7, Global`b8, Global`b9, Global`b10}

How can I get the rid of Global?

DistributeDefinitions didn't help. I use MMA 9.

$\endgroup$
2
  • $\begingroup$ I get your first expression (no Global`` context). I should mention, though, that the default context that I use is Unique to This Notebook`. Perhaps, you set your notebook context too late into the session. $\endgroup$
    – bbgodfrey
    Dec 8, 2014 at 14:24
  • $\begingroup$ My comment above3 is based on MMA10. Using MMA9, I obtain your second result. $\endgroup$
    – bbgodfrey
    Dec 8, 2014 at 16:20

2 Answers 2

2
$\begingroup$

As I commented earlier, with a notebook configured as in your question, I obtain your first answer with MMA V10 and your second answer with MMA V9. Evidently, Wolfram Inc identified the V9 behavior as a problem and fixed it in V10. Since the problem occurs for ToExpression run in ParallelTable, perhaps

ToExpression[ParallelTable["b" <> ToString[j], {j, 1, 10}]]

would address your need, depending on what you are trying to accomplish.

$\endgroup$
0
$\begingroup$

When I change my settings: Menu bar >> Evaluation >> Notebook's default context >> Global', I get the desired output

{b1, b2, b3, b4, b5, b6, b7, b8, b9, b10}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.