Documentation
Getting Documentation
Mathematica has a rich, if somewhat overly complex documentation system. To learn about a given symbol there are a few things you can do. Probably the quickest is to use the built in function Definition
which prints out the description all the definitions on a symbol. You can do this by putting ?
before a symbol
?Print
?Plot
?Quantity
?GeneralUtilities`PrintDefinitions
To find out the most about a symbol it’s best to use the built in documentation notebooks however. Just type a symbol name and click the icon in the little menu that appears. This will open the Documentation Center where you can look around, find links to other functions and symbols, explanations, and most crucially examples.
This menu can also be gotten by placing the cursor immediately following a symbol name or piece of one and pressing +K
Another way to open the documentation center is to highlight a piece of text and press ++F. This is often more useful, as getting the icon to appear can be annoying and this also works in any environment.
Documentation Issues
Mathematica has no automatic documentation procedure. It’s all done manually. This allows for commonly used function to be incredibly well documented, but also means that less used functions get somewhat short shrift and many aren’t documented at all (although this is often intentional, as a feature isn’t ready for prime-time)
Another common problem is that Mathematica’s built in autocomplete features only match from the beginning of the word you’re typing. Say you know there should be a function that converts a number into a string, so you start typing something like NumberToString
, but as you’re typing you notice Mathematica will give you NumberString
, but when you check its documentation page its not what you wanted at all. For that, I provide the following helpful function using the built in function Names
:
FindMySymbol[piecesOfAName__String]:=
Riffle[
ConstantArray[
Alternatives[piecesOfAName],
Length@{piecesOfAName}
],
___
]//
Append[#,___]&//
Prepend[#,___]&//
StringExpression@@#&//
Names
And we’ll see that this works:
FindMySymbol["String","To"]
(*Out:*)
{"ByteArrayToString","StringToByteArray","StringToStream","ToString"}
Notice it won’t find anything if we use all parts of our name:
FindMySymbol["String","To","Number"]
(*Out:*)
{}
But that’s okay. Just add or drop pieces as necessary. Or use the following and just provide a guess of your name:
GuessedSymbols[nameGuess_String, matchComponents_:2]:=
With[{nameSegments=
SequenceCases[
StringSplit[nameGuess,
l_?UpperCaseQ:>l],
s:{_?UpperCaseQ,_?(LowerCaseQ@StringTake[#,1]&)}:>StringJoin@s
]},
FindMySymbol[Sequence@@#,False]&/@
Subsets[nameSegments,{matchComponents}]//
Join@@#&//DeleteDuplicates
];
GuessedSymbols[name_Symbol,matchComponents_:2]:=
GuessedSymbols[ToString@name,matchComponents]
To verify it works:
GuessedSymbols@"StringToNumber"
(*Out:*)
{"ByteArrayToString","StringToByteArray","StringToStream","ToString","NumberFieldClassNumber","NumberString","ToNumberField"}