I would like to be able to use ResourceFunction's as top-level symbols:

enter image description here

The reason being that some of them are so useful it would be really great not to have to type out ResourceFunction["FunctionName..."] each time.

Is there some way to load them all into System context once? For a bonus: add documentation locally.

The first issue is that I don't know how to find them all:



I dug and found where the names for the autocomplete are cached:

names = ResourceSystemClient`Private`publicResourceInformation["Names"]["Function"];

If that doesn't work do this:

names =
  ResourceSearch[{"ResourceType" -> "Function", "Name" -> "*"}, MaxItems -> 1000][[All, "Name"]] // Normal;

Now you can do something like:

 "System`" <> # & /@ names, 
  With[{sn = SymbolName[Unevaluated[#]]},
   SetDelayed[#, # = ResourceFunction[sn]]

And all the resource functions are dynamically loaded into the "System`" context

  • $\begingroup$ Looks like names has only 62 of the 447... $\endgroup$
    – M.R.
    Apr 28 '19 at 22:28
  • $\begingroup$ And wouldn't With[{u = ToExpression[#]}, u := ResourceFunction[#]] & /@ names be simpler... $\endgroup$
    – M.R.
    Apr 28 '19 at 22:49
  • $\begingroup$ @M.R. with all that I'm making sure a) the symbol doesn't already have an OwnValue and b) that ResourceFunction isn't evaluated multiple times. b) only covers a small bit of overhead, but it's a harmless little efficiency. As for names not having everything, you might need to reload the paclet? I have 485 entries in it. $\endgroup$
    – b3m2a1
    Apr 29 '19 at 16:26
  • $\begingroup$ That makes sense. But after running PacletUpdate["ResourceSystemClient"] I have Paclet["ResourceSystemClient", "1.12.0", <> ], and it's only showing 69 names... $\endgroup$
    – M.R.
    Apr 29 '19 at 17:45
  • 1
    $\begingroup$ Right, ok so we get this behavior for free it seems. $\endgroup$
    – M.R.
    May 1 '19 at 18:31

There is a helpful function named PersistResourceFunction that permanently stores a function.

Here is what I did:

<< ResourceSystemClient`;
names = ResourceSystemClient`Private`publicResourceInformation["Names"]["Function"];
PersistResourceFunction /@ names;

I'll post how I did it by scraping, but it's not a great solution:

html = Import[
names = StringCases[html, 
   "<h3>" ~~ Whitespace ~~ "<a " ~~ Shortest[__] ~~ ">" ~~ 
     x : Shortest[__] ~~ "</a>" :> x];
With[{u = ToExpression[#]}, u := ResourceFunction[#]] & /@ names

Then we have all of them

enter image description here

In the system context

enter image description here

Then they load on demand, but trying to load all at once takes 16 minutes:

enter image description here

I haven't found a way to cache them and or to load the docs locally yet...


Just do

DynamicMap = ResourceFunction["DynamicMap"]

and now you can use

DynamicMap[# + 1 &, Range[100]]

as expected.

  • $\begingroup$ Right, but see the updates... how to do for all programmatically? That's the tricky part. $\endgroup$
    – M.R.
    Apr 23 '19 at 17:22
  • $\begingroup$ that is the first thing I thought of, but there might be a bug in ResourceSearch... $\endgroup$
    – M.R.
    Apr 23 '19 at 17:44
  • $\begingroup$ Ah, my apologies, I didn't see your edit before answering. $\endgroup$
    – Carl Lange
    Apr 23 '19 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.