Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find the index of the first element satisfying a criterion
ResourceFunction["SelectFirstIndex"][{e1,e2,…},crit] gives the first i for which crit[ei] yields True. | |
ResourceFunction["SelectFirstIndex"][list,crit,default] gives default if no element yields True. | |
ResourceFunction["SelectFirstIndex"][crit] is the operator form of ResourceFunction["SelectFirstIndex"]. |
Find the index of the first element satisfying a criterion:
| In[1]:= |
| Out[1]= |
When no element can be found, a Missing object is returned:
| In[2]:= |
| Out[2]= |
Specify the default value for the missing element:
| In[3]:= |
| Out[3]= |
Use the operator form of SelectFirstIndex:
| In[4]:= |
| Out[4]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License