13

I'm trying to search for an answer to "What is the complete list of single capital letters that represent built-in Mathematica commands, symbols, or uses?"

For example:

C, D, E, I, N, O

Is this the complete list? I'm teaching linear algebra in the fall, and I will warn students about using variable names that start with capital letters, but I'd also like to be specific about which particular letters will cause a problem.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
David
  • 14,883
  • 4
  • 44
  • 117

4 Answers4

13

To convert my comment into an answer: one can naively run Select[Names["System`*"], StringLength[#] == 1 &] to pick out built-in symbols that are only one character long. This will work in older versions of Mathematica, but ever since the introduction of formal symbols (which are, to be fair, in the System`​ context and are one-character expressions as well), this needs to be finessed further. Thus, we must add extra criteria to filter out the classical list of reserved capital letters (as of the current version):

Select[Names["System`*"], StringLength[#] == 1 &&
                          UpperCaseQ[#] &&
                          StringFreeQ[CharacterName[#], "Formal"] &]
   {"C", "D", "E", "I", "K", "N", "O"}

A (more expensive) alternative uses the new entity framework through WolframLanguageData[] like so:

Select[WolframLanguageData[], StringLength[CanonicalName[#]] == 1 &] // CanonicalName
   {"N", "C", "I", "O", "D", "E"}

but this misses K, which is the arbitrary index used for explicit sums and products returned as solutions by symbolic functions (akin to the use of C as an arbitrary constant). (Try e.g. RSolve[x[k + 1] == x[k] Prime[k], x, k].)

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
12

They are:

C D E I K N O

It's easy to know. Just open a notebook and type the capital alphabet. Those changing color to black are protected.

ans

AHB
  • 311
  • 1
  • 12
8

With a fresh kernel, use

Select[CharacterRange["A", "Z"], NameQ]

{"C", "D", "E", "I", "K", "N", "O"}

kglr
  • 394,356
  • 18
  • 477
  • 896
7
Quiet[Select[CharacterRange["A", "Z"], Context[#] == "System`" &]]
{C, D, E, I, K, N, O}

Hope this can help.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
yode
  • 26,686
  • 4
  • 62
  • 167
  • This did not work for me. I entered Select[CharacterRange["A", "Z"], UnsameQ[Context[#], $Context] &] and got things like: Context::notfound: Symbol A not found. >> and General::stop: Further output of Context::notfound will be suppressed during this calculation. >> even though I first quit the kernel. – David Jun 08 '16 at 18:00
  • In Mathematica 10.4 I needed to add ToExpression thus Select[ToExpression /@ CharacterRange["A", "Z"], UnsameQ[Context[#], $Context] &] – mikado Jun 08 '16 at 19:17
  • Sorry @David ,maybe I miss something yesterday.And I have a verification just now. – yode Jun 08 '16 at 23:45
  • @yode No need to be sorry. That worked. I totally appreciate your help. – David Jun 09 '16 at 04:05