Mathematica Asked by pion on December 16, 2020
When I provide a list of local variables to Module, it complains that it is not a list:
v = {x, y};
Module[v, x = 2]
… Module: Local variable specification v is not a List.
So my question is how do I achieve the above (with list v specified outside of Module) without error?
Module[{x},expr]
specifies that occurrences of the symbols x in expr should be treated as local.
When you forget to put x in {}
, you will get this
In[1]:= Module[x, y]
During evaluation of In[1]:= Module::lvlist: Local variable specification x is not a List.
Out[1]= Module[x, y]
The correct way is:
In[2]:= Module[{x}, y]
Out[2]= y
Answered by Nam Nguyen on December 16, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP