Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create an operator that applies a function over data at a specified level
ResourceFunction["ApplyLevel"][f,levelspec][data] applies the function f over data at the level set forth in levelspec. |
Create an Apply function that will apply a function f exclusively at parts of the expression lying at level 2:
In[1]:= | ![]() |
Out[1]= | ![]() |
Apply the function just created to an expression that is of depth 4:
In[2]:= | ![]() |
Out[2]= | ![]() |
ApplyLevel works with Association, just as Apply does:
In[3]:= | ![]() |
In[4]:= | ![]() |
Out[4]= | ![]() |
ApplyLevel works on SparseArray objects just as it would on the corresponding ordinary lists:
In[5]:= | ![]() |
Out[5]= | ![]() |
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
Turn an Association in which the values are lists of vertex pairs into lists of undirected edges:
In[8]:= | ![]() |
In[9]:= | ![]() |
Out[9]= | ![]() |
Now convert the result into a multigraph:
In[10]:= | ![]() |
Out[10]= | ![]() |
Compute the density of all the planetary moons, by first retrieving the planets Dataset:
In[11]:= | ![]() |
Out[11]= | ![]() |
Now use ApplyLevel as part of a pipeline of operators:
In[12]:= | ![]() |
Out[12]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License