One of the great features of Mathematica is its flexibility . For example, if a particular definition annoys you, it is often very easy to write a modified version that fits your sensibilities (barring unexpected results).
For example SyntaxLength , in my opinion, returns bizzare results in cases where the answer is greater than the length of the input string. This immediately suggests the definition of ActualSyntaxLength:
In[]:=
ActualSyntaxLength@arg_String:=If[(SyntaxLength@arg)>(StringLength@arg),0,SyntaxLength@arg]
To explore ramifications of ActualSyntaxLength we define sanitycheck:
In[]:=
sanitycheck@arg_String:=(ActualSyntaxLength@arg)<=(StringLength@arg)
It is the hope of the author that sanitycheck yields True for each and every member of the set of all strings.
One of the problems is that I have no idea what, in the context of Mathematica, comprises the set of all strings. Nonetheless, we can at least start to consider the set of all single-character strings. Our usual alphabet contains a mere 52 upper and lower-case letters, but Mathematica appears to be somewhat more expansive. For present purposes, though, we will settle for just 1,000,000 single character strings:
In[]:=
singles=FromCharacterCode/@Range@1000000;
Being free of duplicates, singles is indeed a set:
In[]:=
Length@Union@singles
Out[]=
1000000
All elements are single - character strings :
In[]:=
Head/@singles//Tally
Out[]=
{{String,1000000}}
In[]:=
StringLength/@singles//Tally
Out[]=
{{1,1000000}}
We obtain the sought-after result :
In[]:=
sanitycheck/@singles//Tally
Out[]=
{{True,1000000}}
I have used Mathematica since 1992 and remain impressed .