Linked Questions

2
votes
3answers
237 views

How can I assign many values each to a different variable? [duplicate]

How can I assign many values each to a different variable? For example, I want to set $a = f(1),\,b = f(2),\,c = f(3),\,\dots,\,z = f(26)$ (generally more variables than these). How can I do this ...
3
votes
2answers
158 views

Is it possible to set values for a list of variables using a for loop? [duplicate]

Let me preface this question by noting that this is a simple example meant to clarify what I am asking. The actual context in which I want to implement this involves associations containing hundreds ...
3
votes
2answers
47 views

How to convert a list of names and values into a series of expressions [duplicate]

I had an Excel spreadsheet with a list of symbols names in the first column and a list of values in the second column. I imported it. Working with the resulting expression, I now have (in Mathematica) ...
4
votes
0answers
104 views

How to get Symbol[“x”]=3 to work [duplicate]

This is probably a really simple one, but I'm stumped. I want Symbol["x"]=3 to work just like x=3. However I can't figure out ...
0
votes
1answer
73 views

Assign a value to the protected string [duplicate]

How can I assign a value for a symbol composed of a string plus and another string converted from integer? n=3; Symbol["as"<>ToString[n]]=4; So I want to ...
2
votes
0answers
57 views

Import names into notebook namespace [duplicate]

I have function that at some point has list of strings (e.g. {"apple","pear"}) and I want to declare (initialize) those variables in notebook namespace to default ...
0
votes
0answers
47 views

Symbol created in Module not seen outside of Module scope [duplicate]

I am using a function defined with a Module[]. In the Module I am creating a new variable name using a ...
1
vote
1answer
32 views

InputField with a symbol’s name [duplicate]

Suppose I have an InputField of type String wherein I want to enter a symbol name that I want a later Button to assign values to. That button would then do something like: ...
0
votes
0answers
24 views

Evaluating a String that is a Variable [duplicate]

I have a Variable assigned a value, say ImportantDocuments=1 How do I make N["ImportantDocuments"] evaluate to be 1 instead of ImportantDocuments I found that N[ToExpression["...
0
votes
0answers
20 views

How can I create a variable named from a concatenation of strings and assign it a value created similarly? [duplicate]

I have got a list of strings, a = {"first","second","third"}. For each of those strings I would like to create a variable called "The" followed by its content, so ...
0
votes
0answers
17 views

Transform String to Expression [duplicate]

I have a variable postVector and another called CHKpostVector. Both are global variables. Only the variable ...
528
votes
19answers
132k views

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
67
votes
10answers
3k views

Injecting a sequence of expressions into a held expression

Consider the following toy example: Hold[{1, 2, x}] /. x -> Sequence[3, 4] It will give Hold[{1, 2, Sequence[3, 4]}] ...
78
votes
6answers
2k views

How to avoid nested With[]?

With[ {v1 = #}, With[ {v2 = f[v1]}, g[v1, v2] ] ] How to avoid nested With[] like the above? I'd like to use <...
22
votes
4answers
2k views

Elegant manipulation of the variables list

I have a list of global variables (some of them are indexed variables), for example: varsH = Hold[U0[1], U0[2], B0, V0[1], V0[2]] Or (if it is easier to handle) ...

15 30 50 per page