Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
ApplyLevel
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. |
Examples
Basic Examples (2)
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]= |
Scope (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]= |
Applications (2)
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]= | ![]() |
Neat Examples (2)
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]= | ![]() |
Publisher
Version History
- 1.0.0 – 27 January 2020
Related Resources
Related Symbols
License Information
This work is licensed under a Creative Commons Attribution 4.0 International License
![density = #1/(4/3 \[Pi] #2^3) &;](https://cdn.statically.io/img/www.wolframcloud.com/obj/resourcesystem/images/944/94444d3b-d884-4aef-971d-ee99d84b6c1e/5fe610846dd832bb.png)
![ResourceFunction["ApplyLevel"][
density, {2}][<|"Moons" -> <|"Phobos" -> <|"Mass" -> Quantity[1.0724880884600402`3.9586073148417724*^16, "Kilograms"], "Radius" -> Quantity[11.1`3., "Kilometers"]|>, "Deimos" -> <|"Mass" -> Quantity[1.468340774924336`1.9995659225206786*^15, "Kilograms"], "Radius" -> Quantity[6.2`2., "Kilometers"]|>|>|>]](https://cdn.statically.io/img/www.wolframcloud.com/obj/resourcesystem/images/944/94444d3b-d884-4aef-971d-ee99d84b6c1e/32b1c5e42e2769fa.png)




