Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Select elements at a certain level that satisfy a criterion
ResourceFunction["SelectAtLevel"][list,crit,level] picks out all elements ei of list at level level for which crit[ei] is True. | |
ResourceFunction["SelectAtLevel"][crit,level] represents an operator form of ResourceFunction["SelectAtLevel"] that can be applied to an expression. |
Select prime numbers from a list of lists:
In[1]:= |
Out[1]= |
Select odd numbers in a deeply nested and ragged expression:
In[2]:= |
Out[2]= |
Create an operator for SelectAtLevel:
In[3]:= |
Out[3]= |
Use the operator:
In[4]:= |
Out[4]= |
The head does not need to be List:
In[5]:= |
Out[5]= |
All parts of list should at least be level deep:
In[7]:= |
Out[7]= |
This work is licensed under a Creative Commons Attribution 4.0 International License