Capital Letters that are built-in symbols

11

3

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.

David

Posted 2016-06-08T05:08:18.093

Reputation: 14 143

5Try running Select[Names["System`*"], StringLength[#] == 1 && UpperCaseQ[#] && ! StringMatchQ[ToString[FullForm[#]], "*Formal*"] &]. – J. M.'s ennui – 2016-06-08T05:16:24.610

7Just say no to any capital initials. – ciao – 2016-06-08T05:16:45.367

@J.M. Looks like an answer to me. – C. E. – 2016-06-08T05:37:00.077

3Cases[Names["System`*"], Alternatives @@ CharacterRange["A", "Z"]] – Algohi – 2016-06-08T05:38:02.910

@C. E., but not as it stands; I'll write something a bit longer later, unless you want to do so on my behalf. :) – J. M.'s ennui – 2016-06-08T05:38:12.613

@J.M. how did you format your comment in code format. I couldn't do it with the context System` :( – Algohi – 2016-06-08T05:39:44.997

@AHB it is there you can see it but it did not work becase we have one from the context System – Algohi – 2016-06-08T05:41:09.613

1I have edited your comment, @Algohi; the trick is to enclose any snippet with a backtick within two sets of backticks. – J. M.'s ennui – 2016-06-08T05:41:11.897

@J.M. Aha, so I had previously three backticks. Got it. Thanks :) – Algohi – 2016-06-08T05:42:25.933

1

However, note, that K is the only one among standard latin capitals that is not Protected. Also, some of the one-letter formal symbols are Systemsymbols, but not all: compareAttributes@{[FormalPhi], [FormalCurlyPhi]}` (see here).

– István Zachar – 2016-06-08T07:07:34.180

Answers

11

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 ennui

Posted 2016-06-08T05:08:18.093

Reputation: 115 520

11

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

Posted 2016-06-08T05:08:18.093

Reputation: 301

24It's also easy to remember: ONE D--- Never mind. – Peltio – 2016-06-08T05:37:18.110

2@Peltio, don't you start. :P – J. M.'s ennui – 2016-06-08T05:41:43.000

@AHB What does "type the capital alphabet" mean? I can't get this to work. – David – 2016-06-08T18:02:19.517

3He's telling you to type each capital letter manually in each cell, @David. – J. M.'s ennui – 2016-06-08T18:26:12.213

@J.M Aha! I get it. Thanks to both of you. – David – 2016-06-09T04:08:43.957

@Peltio I'm so pure boy.When I realize this,your this comment come to my mind. :) – yode – 2016-07-11T18:28:00.207

@Peltio Although years have passed, I cannot still get your first comment. What did you mean? – AHB – 2018-04-11T18:29:44.547

@AHB this will take some creativity on your end, how to arrange the letters. – doublefelix – 2020-04-24T14:53:37.717

7

With a fresh kernel, use

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

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

kglr

Posted 2016-06-08T05:08:18.093

Reputation: 302 076

6

Quiet[Select[CharacterRange["A", "Z"], Context[#] == "System`" &]]
{C, D, E, I, K, N, O}

Hope this can help.

yode

Posted 2016-06-08T05:08:18.093

Reputation: 19 940

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 – 2016-06-08T18:00:30.523

In Mathematica 10.4 I needed to add ToExpression thus Select[ToExpression /@ CharacterRange["A", "Z"], UnsameQ[Context[#], $Context] &] – mikado – 2016-06-08T19:17:11.480

Sorry @David ,maybe I miss something yesterday.And I have a verification just now. – yode – 2016-06-08T23:45:15.850

@yode No need to be sorry. That worked. I totally appreciate your help. – David – 2016-06-09T04:05:45.083