My codes are shown in the picture attached.

I'm writing codes for numerical calculations frequently, and I think it looks neat and clear to organize input parameters in the form of table. For example,

calcTable=Grid[{{gridNum, tWindow, calcStepPerStep, dataSavingStep}, 
            {8192, 200.*tPulse, 32, 32}}, Dividers -> All]

MapThread[Set, {#[[1, 1]], #[[1, 2]]}] & @ calcTable;

This would be displayed in a form of table in the frontend, and I can easily check and change every parameter.

However, if I want change some of the parameters displayed in the table after I have run the program once, warning appears, and no change of the values can be observed.

I think there must be some misunderstanding in the usage of Set in the MapThread. It can be seen that during the evalutation of

 MapThread[Set, {#[[1, 1]], #[[1, 2]]}] & @

parameters such as {gridNum, tWindow, calcStepPerStep, dataSavingStep} has been assigned with its value at the first place.

Actually, I'd like the evaluation performed in this way, first take {gridNum, tWindow, calcStepPerStep, dataSavingStep} literrally, then use Set to assigned values to them by MapThread. I think this is closely related to nonstandard evaluation. But how can I achieve this?

Thank you very much.

enter image description here

  • $\begingroup$ closely related: 103263 and a possible duplicate: 84284. $\endgroup$
    – Kuba
    Commented Jun 15, 2016 at 12:58

1 Answer 1


Fundamentally this is a very common question:

The defined Symbols are evaluating before Set ever sees them.

I would need to see how you are actually using this to make a proper recommendation but for the single example given you might wrap the entire thing in HoldForm and Apply the Set like this:

calcTable = 
   {{gridNum, tWindow, calcStepPerStep, dataSavingStep}, {8192, 200.*tPulse, 32, 32}},
   Dividers -> All
 ] // HoldForm

Set @@@ calcTable[[{1}, 1]] // ReleaseHold

You can redefine the Symbols with a second table:

calcTable2 = 
   {{gridNum, tWindow, calcStepPerStep, dataSavingStep}, {foo, bar, 3.14, 42}},
   Dividers -> All
 ] // HoldForm

Set @@@ calcTable2[[{1}, 1]] // ReleaseHold

The Symbols have the new definitions:

{gridNum, tWindow, calcStepPerStep, dataSavingStep}
{foo, bar, 3.14, 42}

I find this a rather clumsy way to handle Symbol assignment however and I imagine that a different approach will ultimately be superior. (Please see the referenced Q&A's for examples.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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