1

This is for examples in documentation I'm writing for a ResourceFunction["PrettyOptions"] (look for it soon) that is close to completion. Asking for most common ones with varying numbers of Options Rule-s and DelayedRule-s which is why the request is for several. If you can supply a few (the more, the merrier) offhand, I would really appreciate it. Thank you.

EDIT: I know this is a meta or community something question, however I don't know how to get there or how to transport this over. If you're an admin please move it there.

Jules Manson
  • 2,457
  • 11
  • 19
  • 2
    Here's the link to the meta site: https://mathematica.meta.stackexchange.com/ if you need it. However, I'm not sure this would be appropriate there: it's not a question about the site, which is what would be appropriate for meta. I just don't fully understand what you are seeking in your question: could you expand a bit further? – MarcoB Dec 08 '22 at 12:43
  • 1
    I'm not even sure this is for [meta] it's very hard to understand what the OP is asking here or how are we supposed to help. I have voted to close this question because it "Needs details or clarity". The OP should [edit] the question to avoid or revert closure. – rhermans Dec 08 '22 at 15:29
  • 1
    If the question was "How to find all or randomly 10 system functions for which Options[function] yields a list of both rules and delayed rules" then I would not see any reason to close it. One of them is Plot as can be seen with Options[Plot]. Integrate as well and probably every function that relies on the global variable $Assumptions. – userrandrand Dec 08 '22 at 18:43
  • @MarcoB i was hoping there was a meta or community wiki link somewhere on this page where i could port this post to there. – Jules Manson Dec 15 '22 at 00:49

1 Answers1

4

TL;DR: maybe use

filteredClass=FilteredEntityClass[EntityClass["WolframLanguageSymbol", All], 
      EntityFunction[e, 
       Not[FreeQ[#, _RuleDelayed] ∨ FreeQ[#, _Rule]] &@e["Options"]]];

Then :

filteredList = filteredClass // EntityList;

or for a random list of names

filteredClass[EntityProperty["WolframLanguageSymbol", "Name"]] // 
 RandomChoice[#, 50] &
{DensityPlot3D,Asymptotic,ListLogLinearPlot,DictionaryWordQ,Expectation,InverseFourierSinTransform,HumanGrowthData,InitializationValue,DiscreteMaxLimit,Dendrogram,FunctionContinuous,ExternalStoragePut,ListStepPlot,Play,CreateWindow,AbsoluteTime,CurrentImage,Area,SliceDensityPlot3D,KagiChart,DSolve,FeatureImpactPlot,ImageMesh,ReImPlot,CloudSubmit,DiscretePlot,ClockGauge,PossibleZeroQ,Solve,PopupWindow,TimeSeries,HighlightImage,ListVectorDisplacementPlot,FourierSinTransform,RegionWithin,SemidefiniteOptimization,ContinuedFractionK,GeoGraphPlot,RegionDilation,NotebookPut,WikidataData,FindFit,ResourceFunction,VectorPlot,ExternalStorageUpload,BlockchainBlockData,TimeSeriesShift,LogPlot,DensityPlot3D,VectorDisplacementPlot3D}

Note : The options with RuleDelayed seem to often rely on global variables such as $Assumptions or $PlotTheme as such variables are susceptible to change. In other cases there are functions such as StandardForm, a pure form FrontEndExecute and there is also a True in the mix that I do not understand

If you want the list of all system functions that have both Rule and RuleDelayed then one possibility is to use the Entity framework. As an attempt to make this often obscure part of Mathematica a bit easier to understand I will proceed step by step in a series of questions for pedagogical purposes and a bit for my amusement.

The question:

How can I get a list of system functions for which Options[function] yields a list of both rules and delayed rules ?

  • Reflex $\longrightarrow$ A question about data $\longrightarrow$ Entities

  • Where should I look ?

The documentation here has a list of entity "types".

These are broad categories like "Chemistry", "Language" , etc.

Another possibility is to use EntityValue[] to get a list of entity types.

Search for "Wolf" in that list you might find :

"WolframLanguageSymbol"

That is the best looking candidate.

Now "WolframLanguageSymbol" is what is called an entity type. That type name encapsulates a list of entity classes and each entity class encapsulates entities. Entities are the fine grained objects like "apple" whereas an entity class is something more broad like "fruits".

So:

Step 1: What entity classes are in this type ? Will it really be of any use to me ?

To check the classes you can use:

EntityClassList["WolframLanguageSymbol"]

enter image description here

In that list

enter image description here

looks like the best candidate.

Step 2: What can we ask ?

That class encapsulates many entities. Each entity is a Wolfram Language symbol such as Plot. To check what we can ask we can use:

enter image description here

In that list we will see "options"

To check that that is really the options for the symbol we could take a random entity with RandomEntity

enter image description here

Entity["WolframLanguageSymbol", "InverseJacobiSC"]["Options"]

(* {} *)

Correct !

As can be checked with

InverseJacobiSC // Options

(* {} *)

For the reader that is not convinced, after trying RandomEntity a few times you might find something like Entity["WolframLanguageSymbol", "Fourier"] which gives a non empty list.

Step 3 : Filtering results

Ok now how do we filter the entities that suit the request from the original question ?

$\longrightarrow$ FilteredEntityClass

One may define an EntityFunction that filters out what we want.

So what do we want ?

Now comes the usual Mathematica code. We want a list of functions that contains RuleDelayed and Rule. Those explicit names can be found with FullForm. How do we ask whether a list contains a pattern ? We could use Cases or Select and Length but FreeQ seems closer to what we want although it is the negation of what we want. Hence, we could use double negation, that is,

Not[Not[a && b]]

If we do not remember or know how that goes we can use :

Not[a && b] // LogicalExpand

(* ! a || ! b *)

So we can set up a filtered entity class with

filteredClass=FilteredEntityClass[EntityClass["WolframLanguageSymbol", All], 
  EntityFunction[e, 
   Not[FreeQ[#, _RuleDelayed] ∨ FreeQ[#, _Rule]] &@e["Options"]]];

Then use :

filteredList = filteredClass // EntityList;

For more information on entities I started a post here. I plan on updating my answer there with a concrete example and utility functions to facilitate searching in the future.

userrandrand
  • 5,847
  • 6
  • 33