The Wolfram Language has more than 5000 built-in functions and constants.
functionslist = Flatten[
Names[#] & /@ Flatten[
{# <> "*", "$" <> # <> "*"} &
/@ CharacterRange["A", "Z"]
]
];
Length @ functionslist
5689
OK, 5689 have documentation in Mathematica 10.3, to be more precise. In order to keep up with that, I would like to pick randomly a function documentation to refresh.
SystemOpen["paclet:ref/" <> RandomChoice[functionslist]]
But I would like to refresh new functions more often than old ones.
SystemOpen["paclet:guide/SummaryOfNewFeaturesIn103"]
How can we implement a "New function of the day" function that focuses on functions new to the current version?
Bonus if it picks from all functions with decaying probability as a function of "age".
Code adapted from this question.
Answer
Here is an alternative procedure using EntityValue[] and Dataset[]. The idea is to build a Dataset[] containing function names and the version numbers they were introduced in, and then use a query to pull all the names that are new in a particular version. One can then pick any of these names randomly. A way to bias newer functions over older ones is to use RandomChoice[] on the list of version numbers, with each version number being its own weight.
$versions = {1, 2, 2.2, 3, 4, 4.1, 4.2, 5, 5.1, 5.2, 6, 7, 8, 9,
10, 10.1, 10.2, 10.3};
symtable = Dataset[AssociationThread[{"Name", "VersionIntroduced"}, #] & /@
EntityValue["WolframLanguageSymbol", {"Name", "VersionIntroduced"}]];
randomHelpPage := With[{version = RandomChoice[$versions -> $versions]},
SystemOpen["paclet:ref/" <> RandomChoice[Normal[
symtable[Select[#VersionIntroduced == version &], "Name"]]]]]
Button["Random WL Function", randomHelpPage]
This should now function in a similar manner to Jason's solution.
Comments
Post a Comment