Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Map a function over selected elements of a list, also passing in a running count of such elements
ResourceFunction["MapSelectCounted"][f,list,test] returns a list of f[xi,j] where j is a running total incremented when test[xi] is True. | |
ResourceFunction["MapSelectCounted"][f,list] returns a list of f[xi,i] for all elements xiin list. |
Map while keeping the count:
| In[1]:= |
| Out[1]= |
MapSelectCounted over a list conditionally:
| In[2]:= |
| Out[2]= |
Oftentimes you only need the first part of the second slot of MapIndexed
| In[3]:= | ![]() |
| Out[4]= | ![]() |
MapSelectCounted only works at the first level, use MapIndexed to specify deeper levels than the first:
| In[5]:= |
| Out[5]= |
| In[6]:= |
| Out[6]= |
This work is licensed under a Creative Commons Attribution 4.0 International License