# Creating a List of Symbolized Indexed Variables

I am trying to creat a list of indexed variables (symbols) using the Notation package and Symbolize command.

As an example, suppose that I want to a creat a list of variables like ${x_1,...,x_{20}}$ but I want all of them to be symbols. How can I creat a list of symbolized indexed variables?

• Perhaps you could clarify which part you find unexpected, so we can provide better answers. Perhaps we could start from here: Information (i.e. ??) is HoldAll so it won't evaluate Var[[1]] to its contents. You could try Information[Evaluate[Var[[1]]] instead. More in general, however, when you assign values to subscripted variables, the value is actually associated with the Subscript function, and not with the variable. – MarcoB Jan 23 '17 at 16:30
• See perhaps (1005), (373). – MarcoB Jan 23 '17 at 16:33
• @MarcoB: Ah! So my first question is answered!? :) What about the second one. :) – H. R. Jan 23 '17 at 16:33
• @MarcoB: Please note that if one uses the Symbolize command then there will be no problem for assigning. :) – H. R. Jan 23 '17 at 16:35
• I am not familiar enough with the Notation package to comment on those points. In general, though, I would suggest that you look into Indexed, or simply use e.g. x[1, 3] instead of $x_{1,3}$. See e.g. (114632) and links, and search this site for "alternatives to Subscript". – MarcoB Jan 23 '17 at 16:39

Perhaps you don't need to - you can use a pattern (e.g Subscript[x,_]) inside a Symbolize box. This will generate the symbols as required.

• (+1) Thanks for the attention. :) Yes this would also work. – H. R. Mar 8 '17 at 20:33
• @H.R. if you're indexing by ints greater than 0 note that the pattern that is most protective is _Integer?Positive. – b3m2a1 Mar 8 '17 at 23:29
• @MB1965: That is a nice point. It will be good if you add some nice patterns for different indexing to your answer too. :) – H. R. Mar 9 '17 at 7:49

Here is as simple way to create a list of symbolized variables $x_1,x_2,\dots,x_{20}$ as follows

Clear["Global*"]

Needs["Notation"]

Do[Symbolize[ParsedBoxWrapper[SubscriptBox["x", ToString[i]]]], {i, 1,
20}]

x = 1
(*1*)

Subscript[x, 1]
(*x_1*)

• It's worth keeping in mind that this is just front-end magic. If you used GeneralUtilitiesPrintDefinitionsLocal on Symbolize you find it just constructs a bunch of symbols looking like x\[UnderBracket]Subscript\[UnderBracket]i and then coerces the box representations with MakeExpression and MakeBoxes. It'll work for most simple usages, but it absolutely requires the front end and the Symbolize call to work. Another point of interest: if you want to get the information on such symbols all one needs to use is ?? "x\[UnderBracket]Subscript\[UnderBracket]*". – b3m2a1 Mar 8 '17 at 20:20
• @MB1965: Thanks for the attention. What we see is clearly the front end notation so I find it useful to make use of these things for better readability of the code. :) Also getting information is not that much painful as you say. The keyboard entry is simply "? x crtl+_ 1". :) – H. R. Mar 8 '17 at 20:31
• yes, but if you want the definitions for all of the subscripted symbols you require that (I believe). Information takes a placeholder form with "*" to spit out all matching forms but this has to be a string. Similarly with Clear or Remove`. – b3m2a1 Mar 8 '17 at 20:47