# Defining a variable with comma (or any other separator) in its name?

How can I define Mathematica variable/function with comma in it?

For example, defineL00,1 as a variable?

I plan to use L00,1 as a variable as 00 and 1 have different meanings. Other examples are like L01,1, L10,0, etc. The purpose to comma is to separate meanings when others see it, otherwise L001 will cause confusion. I also hope to avoid l["00",1] as a variable as the " " sign will cause confusion to users not familiar with mathematica interpreting it as string. Any symbol added to the variable that serves as a separator between 00 and 1 would be fine. For example L00;1 or L00_1. But they do not work. The purpose is to inform my user (colleagues) in a reader-friendly way.

If the question is not meaningful please ignore it or inform me.

• Subscript[a, "00", 1] = 12 – Coolwater Jun 5 '16 at 8:32
• It's not possible. Try Symbol["L00,1"] to see the error. – Marius Ladegård Meyer Jun 5 '16 at 9:20
• Why do you want to do this though? Is it just for formatting? – Marius Ladegård Meyer Jun 5 '16 at 9:21
• @kww and I have already shown you two ways to do it. – Marius Ladegård Meyer Jun 5 '16 at 9:32
• kww, this is of course possible. But to help others give you a useful answer, can you edit your question and provide some context about how you plan on using this symbol. -1 until you edit your question. – QuantumDot Jun 5 '16 at 10:58

Here is one possibility:

MakeBoxes[l[a_, b_], form_] :=  RowBox[{"l", "[",
ToBoxes[b], "]"}]


l[00,1] continues to display as l[00,1].

Here is another possibility:

MakeBoxes[l[a_String, b_], form_] :=
With[{string = "\"L" <> a <> "," <> ToString[b] <> "\""},
InterpretationBox[string, l[a, b]]]


l["00",1] displays as L00,1

As it has been pointed out in the comments made to your question, using reserved symbols in identifiers is not allowed. What you can and might want to do is bind expressions to values. The arguments of the expression can serve as indices or tags to produce the kind of differentiation you want.

Here are two examples of what I am alluding to.

a["00", 1] = 3; a["10", 0] = 42;
a["00", 1]^2 + a["10", 0]


51

b[0, 1][x_] := 1 + Log10[x]; b[10, 0] = 42;
b[10, 0]^b[0, 1][2] // N


129.389