38 questions linked to/from Elegant manipulation of the variables list
262 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 ...
608 views

### How to assign values to symbolic arrays [duplicate]

My main question is how to assign values to symbolic arrays, in an efficient way. The code below is a simplified version of what I am trying to do and the output I get. Note that because I am using ...
89 views

### Assign Values from Array to Array [duplicate]

I am trying to simply do the following cVec = {a,b,c,d} From another expression, I obtain another vector, say, ...
124 views

### Table of references [duplicate]

I have a list of variables (say a, b, c, d, e) that I want to assign in a single command. {a,b,c,d,e} = {1,2,3,4,5} would ...
140k 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 ...
3k views

### How to create symbols from strings and set values for them?

I am trying to convert a list of string names into symbols, which will then be used to store data. I have 24 files (where the name of each file is a member of the list mentioned above) that I need to ...
1k views

### Reassign values to symbols

I've got a situation where I have, say 4 symbols, a, b, c and ...
2k views

I have been working on picking expressions apart using Head and Part and encountered a little mystery. Consider the canonical ...
8k views

### Assigning values to a list of variable names

As part of a calculation I need to do something like this Evaluate[{aaa, bbb, ccc}[[ index]]] = {1, 2, 3, 4, 5} so if index is ...
1k views

### Generate list of strings from a list of assigned variables

How do I generate a list of strings from a list of assigned variables? E.g. convert ...
715 views

### How to Clear variables represented as a list of strings?

Say I have a string list called fullpara fullpara={"width", "long", "line", "distance"} And there are corresponding variables ...
1k views

### Why this list has a length of 1?

Here is the code : bb = HoldForm[{aa, bbb, cc, dd}] it returns : {aa, bbb, cc, dd} Which is what I ...
434 views

### Using Block with a list of variables

I have a list of variables var={v1,v2}; which I want to protect/localize during a particular operation. I have decided that I want to use ...
851 views

### How to name a variable with the value of another variable?

A simple but very important (at least for me) question. In some languages for defining a variable, for example, we can do: i=10 "d"&i=30 So I have defined the variable d10, and... d10=30 ...
422 views

### How to create a writable and clearable symbol? [duplicate]

I'm trying to create several symbols and assign values to them. Here's what currently appears to work: Evaluate[Symbol["fdds" <> ToString]] = 1 But ...
155 views

### Using a variable to tell Mathematica which existing variable to manipulate

I have an estimation routine I have coded up, I want now to do some tests on it where I pick a particular parameter and run the estimation for differing values of that parameter. What I want is to be ...
1k views

### Pass the list of variables into function to change their values

I'm new to Mathematica, so I don't really know, how do what I want, and I don't even know how to google it. Doing one Mathematica task for my supervisor, I faced the following problem. I need to ...
247 views

### why set values in this way doesn't work?

question is as follows define a list ttt={1,2}; and if I set values in this way {ttt[],ttt[]}={3,4} then the value ...
146 views

### Can a Dynamic be attached to the single elements of a list?

Consider the following example: ...
190 views

### Why does Evaluate[a[]]=0 assign a value to a variable while a[]=0 doesn't?

I'm trying to do a small page counter with Mathematica, for leting me know about my reading progress on some books. I'm stuck on a problem: ...
398 views

### Printing names of indexed variables instead of values

I'd like to display only the variable (indexed variable) name (in symbol form, not in string form) instead of its value in Mathematica. Say I have a variable foo[i] ...
685 views

### How to assign the values for the Table list?

Now, I want to assign some values for a Table list and I find that If {mat, mat, mat, mat, mat}={4,23,3,12,1}; it is no problem. But, if we use ...
277 views

### How to return the unevaluated variable names from a list of variables which have been declared

I feel like this should have a simple answer but I haven't found anything that works. The toy example of what I want is as follows: ...
225 views

### How do I use a passed-in symbol as a tag to define UpValues?

ClearAll@foo; foo[tag_] := ( tag /: tag[i_] := tag[[i]] ); a = {7, 8, 9}; foo[a]; a I wanted the above to output 8, ...
251 views

### direct assignment to the element in a Table

I have already asked a related question here why set values in this way doesn't work? But I think I have to write the question which I encountered explicitly? ...
138 views

### HoldFirst and Hold expression as argument

I store a reference to the association in a held expression in a variable: a=<||>; b=Hold[a]; And in the code, I want to do manipulations with the original ...
216 views

### A problem with set values

The following code is just an example to clearly explain my problem. Assume that : ...
116 views

### Get the name of a time series while using Table

I saw a number of related questions to the one I'm about to post; they helped, but none of them solved my problem entirely. Get the name of a symbol passed to a function Obtaining the name of a ...
187 views

### How to extract a variable names (not values) from a list of transformation rules?

I am trying to extract variable names from a list of transformation rules mapping = {var1 -> 'val1', var2 -> 'val2' }. Variables ...
95 views

### HoldFirst being overridden by Activate [duplicate]

So here's the problem a=1;a=2 works because of the HoldFirst attribute of Set, so that it ...
90 views

### Set does not work

I tried following code, but it does not work as expected: Do[Set[a[],a[]],{a,{x->2,y->5,z->x+y}}] {x,y,z} I ...
148 views

### How to apply Set to held symbols listed in a variable?

I have a variable states that contains a list of held symbols: ...
229 views

### I am missing a function like HoldPattern

Temporary message: I am planning to edit this question, making the examples less confusing and by moving the things that are confusing to a separate question For any confusion about expressions that ...
68 views

### How to use Set correctly

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,...
119 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 ...
48 views

### How to assign a value to an already existing element of a list? [closed]

I want to do the following. Say I have a list: test = List[a,b,c] and I now want to assign some value to elements of that list, so that say if I assign 4 to a, ...