5
$\begingroup$

Some of the capitalized single letters are functions. Starting a fresh kernel and typing in the 24 capital letters, the following letters turn black since they are special functions,

  • C - an anonymous constant
  • D - derivative
  • E - natural number $e$
  • I - imaginary unit
  • K - ???
  • N - numerical value
  • O - order

The weird thing is that K turns black, but it has no documentation and can be used as a variable without much issue. I only realized this because I was using K as a constant and it caused a ParallelTable to hang (whereas the corresponding Table has no issues), but I have not yet been able to produce a MWE.

So, is K a function? Is it being reserved for something? Is it known that it can potentially cause problems? Or is this a bug?

$\endgroup$
6
  • 1
    $\begingroup$ ? K gives me answer. Is it a satisfactory one to you? If not, why not? $\endgroup$
    – Michael E2
    Apr 8 at 15:33
  • 7
    $\begingroup$ It's relatively easy to remember which symbols not to use. Either don't use capital letters, or don't use the ones that spell ONE and a word that is a reference to the male anatomy; hint it starts with a D and ends with a K $\endgroup$
    – bmf
    Apr 8 at 15:37
  • 1
    $\begingroup$ @MichaelE2 it gives an answer, but it's not documented, right? So I guess the situation is not very satisfactory. $\endgroup$
    – bmf
    Apr 8 at 15:41
  • 1
    $\begingroup$ @xzczd ? K gives a sufficient hint, though (imo). And @ bmf, K::usage is a form of documentation, and usage messages are themselves documented (in the doc pages for Information, MessageName, etc. and related tutorials, for instance, in the aptly named Documentation Constructs). $\endgroup$
    – Michael E2
    Apr 8 at 16:08
  • 1
    $\begingroup$ @MichaelE2 thanks for sharing your thought and providing feedback. I guess what I meant by saying undocumented is the following: see the difference for K and for C. I should have been more explicit. Please don't delete your comment. I think it makes sense to have this comment section here. Many thanks $\endgroup$
    – bmf
    Apr 8 at 16:18

1 Answer 1

8
$\begingroup$
?? K

k

To get them all, I guess the following works

Select[Names["System`*"], 
 StringLength[#] == 1 && 
   UpperCaseQ[#] && ! 
    StringMatchQ[ToString[FullForm[#]], "*Formal*"] &]

all

As far as I can tell, K is the only undocumented capitalized built-in symbol.

$\endgroup$
9
  • $\begingroup$ Thanks, I was not aware of ? or ?? $\endgroup$
    – Kai
    Apr 8 at 16:15
  • $\begingroup$ @Kai glad I was able to help! $\endgroup$
    – bmf
    Apr 8 at 16:16
  • 1
    $\begingroup$ +1 and nice code too. Didn't get your comment on male anatomy until I saw this! $\endgroup$
    – hana
    Apr 8 at 18:32
  • 1
    $\begingroup$ Slightly shorter using Select[Names["System`"~~_] to get 1 letter symbols. $\endgroup$
    – Somos
    Apr 8 at 19:20
  • 1
    $\begingroup$ Side note: Unlike other capitalized built-in symbol, K is not Protected. And, it's strange that, the message is already in v3, but I cannot find an example that actually use it therein!: i.stack.imgur.com/q317q.png $\endgroup$
    – xzczd
    Apr 9 at 2:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.