Write an expression that queries all of MMA to find the top M Symbols with the most Options or M Symbols having N Options?

I apologize, but I'm way over my pay-grade on this one, so I don't have any code to share that needs correcting. That is because I really don't know how to start this. I feel like this has a very easy and short solution, but it evades me (I would not be at all surprised if Kuba came up with a one-liner for each part described below).

Therefore, please allow me to clarify a few things. M and N are both quantities. N does not mean Numerical but it can include Nunerical Symbols. Also, please do not overlook that this is a two-part question:

1. Find top M (i.e. 10) Symbols with the most Options.
2. Find up to M (i.e. 10) Symbols having precisely N (i.e. 24) Options.

Thank you. I look forward to what you might come up with.

Edit: I speculate this could take a few hours to query. I believe there is something like 50,000 Symbols or some big crazy number close to it?

Call "nsymbols" the max. number of symbols searched. Then the names of symbols can be get by "Names". As the names are strings we need to change them into symbols. Then we may use "Options" to get the options of a symbol. "Length" will tell use how many options there are. TakeLargest will extract the nsymbols largest. And "Position" will tell use where in the list of symbols these can be found.

As it can take quit a long time, I am doing it only for symbols beginning with "A...". To get all symbols, you would simply delete the "A":

nsymbols = 4;
lens = Length /@ Options /@ (sym = Symbol /@ Names["A*"]);
pos = Position[lens, #] & /@ TakeLargest[lens, nsymbols] // Flatten;
sym[[pos]]

(* {AuthenticationDialog, ArrayPlot3D, ArrayMesh, AbsArgPlot} *)


For the second question, you would choose a specific length instead of the nsymbols largest., E.g. if we search a symbol starting with "A" and 53 options:

noptions = 53;
lens = Length /@ Options /@ (sym = Symbol /@ Names["A*"]);
pos = Position[lens, noptions] // Flatten;
sym[[pos]]

(* {ArrayPlot} *)


We can check this by:

Options[ArrayPlot] // Length
(* 53 *)

• im familiar with all the symbols used and had no idea they could be combined this way to interrogate MMA, like this. i needed this for finding great examples to work with for an Options ResourceFunction im coding. this is probably the 10th time you helped me. thanks again. :) Commented Nov 19, 2022 at 0:29
• You should be able to shorten this a bit using TakeLargestBy, e.g. something like TakeLargestBy[Symbol /@ Names["A*"], Length @* Options, nsymbols] Commented Nov 19, 2022 at 8:41
• @Jules Manson Glad to be of some help! Commented Nov 19, 2022 at 8:56

One can use free form syntax and Entities.

Type "=" at the beginning of cell to start free form syntax. Then type:

"list of mathematica functions"

EntityList[EntityClass[
"WolframLanguageSymbol",
All]]


I wrote:

then one can check a random entity:

mma //RandomChoice


After a few tries I found something that looked like a function : NicholsPlot.

To get a fast idea of the queries you can ask you can copy paste it into another cell and then use ? at the beginning:

Among the properties you will see OptionNames which shows that one can ask about the options. To get a list of properties one can use ["Properties"]

Scrolling through the properties one finds options so we can copy paste that and use it:

Now putting everything together. Consider a sample:

randmma = RandomChoice[mma, 3];


Then check the options of each using Through:

Note : some symbols without an option also give the result Missing["NotApplicable"]. Maybe there are other types of outputs too.

You might want to build an association to associate each entity with the length of options. You might also want to filter that large list somehow to remove stuff that are not likely to have options. You can maybe check the different properties to find a way to filter out the entities that have property values you are not interested in, not sure.

• I really dig this because i don't know squat bout entities and I know i will love trying it out, but It's not very practical if coding applications. However, this is a kick ass alternative approach example for the documentation of the function I am coding, ResourceFunction["PrettyOptions"]. :) Commented Nov 19, 2022 at 10:12
• @JulesManson I don't know much about Entities either haha. I usually use free form syntax when I think entities might be involved. I wish I understood more as they seem to be the main way to represent knowledge in Mathematica. Not sure if they are practical or not for coding applications. Commented Nov 19, 2022 at 11:03
• @JulesManson Can I get an (insider scoop)/(pre-release information) about what PrettyOptions will do ? From the name I guess it will format Options into a more readable format with maybe colors, classification, and sorting into a table or dataset, maybe some interactive clicking and opening ? Hope I remember to check it out later (:. Commented Nov 19, 2022 at 11:10
• Hello, PrettyOptions sounds like it's going to be nice (:. I think you can also publicly share a notebook on the notebook archive notebookarchive.org but I never did it. I also use a dark theme. I made my own then just decided to use DarkMode from the resource function repository and change it a bit. How do you manage with Graphics, Plots, Graphs and Print ? They have a default black font. I made my own print but I am too lazy for the Plots and Graphics and so on. Commented Nov 20, 2022 at 6:39
• Not sure I want to go through the whole emailing plan but I can maybe update you on what I think on a stack exchange chat once it is published. I do not know how chat's work here though. So yeah unless I confirm that I will send a message, if someone writes to you "userrandrand at stackexchange" it's probably not me and you should probably ignore the message. Commented Nov 20, 2022 at 6:44