Looping through all functions defined in Mathematica
Single-argument functions:
funclist = Select[("ArgumentsPattern" /. SyntaxInformation[#]) === {_} &][
FromEntity /@ MathematicalFunctionData[]];
Grid[Prepend[Thread[{funclist, Through[funclist@2]}],
Item[#, Background -> LightBlue] & /@ {"f", "f @ 2"}],
Dividers -> All]
I am sure there is a way to do this using MathematicalFunctionData
, just to obtain list of functions. But I could not find it. I got lost in help pages of Entities , FromEntity[], ToEntity[], and so on.
Here is lazy person's way of doing it.
isFunction[name_String] := Module[{m},
m = SyntaxInformation[Symbol[name]];
If[Length[m] > 0, True, False]
];
n = 0;
pkg = "System`";
names = Names[pkg <> "*"];
tbl = First@Last@Reap@Do[
Print["Proccesing entry ", k];
If[isFunction[names[[k]]],
n++;
Sow[{n, pkg <> names[[k]]}]
]
, {k, 1, Length[names]}
];
Which gives
{{1, "System`AASTriangle"},
{2, "System`AbelianGroup"},
{3, "System`Abort"},
{4, "System`AbortKernels"},
{5, "System`AbortProtect"},
{6, "System`AbortScheduledTask"}, {7,
.....
{2300, "System`ListLogLinearPlot"},
{2301, "System`ListLogLogPlot"},
{2302, "System`ListLogPlot"},
{2303, "System`ListPicker"},
{2304, "System`ListPickerBox"},
{2305, "System`ListPlay"},
{2306, "System`ListPlot"},
{2307, "System`ListPlot3D"},
{2308, "System`ListPointPlot3D"},
{2309, "System`ListPolarPlot"},
{2310, "System`ListQ"},
{2311, "System`ListSliceContourPlot3D"},
{2312, "System`ListSliceDensityPlot3D"},
{2313, "System`ListSliceVectorPlot3D"},
{2314, "System`ListStepPlot"},
{2315, "System`ListStreamDensityPlot"},
{2316, "System`ListStreamPlot"},
.....
{4431, "System`$DefaultFrontEnd"},
{4432, "System`$DisplayFunction"},
{4433, "System`$FormatType"},
{4434, "System`$FrontEndSession"},
{4435, "System`$SoundDisplayFunction"}}
If when running the above code, you get pop-up windows asking you to login to Wolfram Cloud, just close it. I got such screen many times. I have no idea why it is asking me to login to Wolfram cloud.
Do not worry that they are strings in this list. You could always convert string to Mathematica expression using ToExpression
to use the functions.