First we get a list of the functions, indexed by their introduction date. The method suggested by Szabolics turned out to be very slow - although it has the advantage that it gives a date rather than just the year.
And as Kuba mentioned, the functions gathered by Rhermans's function do not all have help pages, so we just grab the file list from the help pages directory.
functiondatelist = Module[{dir, symbolslist, datelist, mmagrep},
(*
Here I'm scanning only what is in the 'ReferencePages/
Symbols' directory, we could add other directories to scan
*)
dir =
FileNameJoin@{$InstallationDirectory, "Documentation", "English",
"System", "ReferencePages", "Symbols"};
symbolslist = FileNames@FileNameJoin[{dir, "*"}];
Print["Found " <> IntegerString@Length@symbolslist <>
" symbols with help pages"];
(*
Now we scan the notebooks for the phrase "Introduced in" and \
thereby grep the year it was created.
*)
mmagrep[file_, patt_] :=
With[{data = Import[file, "Lines"]},
Pick[Transpose[{Range[Length[data]], data}],
StringFreeQ[data, patt], False]];
Print["Scanning for introduction dates:"];
Monitor[
datelist =
Table[StringCases[
mmagrep[symbolslist[[n]], "Introduced in"][[1, 2]],
DigitCharacter ..][[1]] // ToExpression, {n,
Length@symbolslist}];
, n];
(*Now bin up the list of functions by their year *)
Reverse@SortBy[
GatherBy[
Transpose[{FileBaseName /@ symbolslist,
datelist}], #[[2]] &], #[[1, 2]] &]
];
The symbol-introduction years aren't evenly distributed,
DeleteDuplicates[Flatten@functiondatelist[[All, All, 2]]]
(* {2015, 2014, 2012, 2010, 2008, 2007, 2005, 2004, 2003, 2002, 2000,
1999, 1996, 1993, 1991, 1988} *)
Choose some directory in your $Path
where you like to keep packages, and create a folder titled RandomHelp
to write this data to. I don't mind having a cluttered home directory so I just use
Export[FileNameJoin[{directoryinyourpath,"RandomHelp", "mma_symbollist.m"}],
functiondatelist];
Copy this text either into a text file named init.m
inside the RandomHelp
directory,
{symbollist, symbolintyears} =
Module[{temp},
temp = Import[FileNameJoin[{"RandomHelp", "mma_symbollist.m"}]];
{temp[[All, All, 1]],
DeleteDuplicates[Flatten@temp[[All, All, 2]]]}];
randomintroductionyear := Module[{test, gamma},
gamma = 0.15;
test = Length@symbolintyears + 1;
While[test > Length@symbolintyears,
test = Ceiling@RandomVariate[ExponentialDistribution[gamma]];
];
test
];
randomnewhelppage :=
Module[{year, symbol},
year = randomintroductionyear;
SystemOpen[
"paclet:ref/" <>
symbollist[[year, RandomInteger[{1, Length@symbollist[[year]]}]]]]
];
Button["Procrastination Button", randomnewhelppage]
If you want to increase the bias towards the new, simply make the gamma value larger. Here I have gamma set to 0.15 and 0.5, respectively
Save the init.m
file, and now all you have to do is type
<< "RandomHelp`"
and you get a nice button
FileBaseNames
in References directory. To get dates you can prse the notebook to get "History" cell.ImportNotebook
would be of great help but it is quite slow in context of 5k repetitions. $\endgroup$WolframLanguageData["ArrayReshape", "DateIntroduced"]
may be useful. $\endgroup$init.m
file it would pop up a new function every time you restarted the kernel. Is there some equivalent file that only loads when you open the frontend? $\endgroup$