Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create an association from a set of values, using a map-indexed function on those values to form the keys
ResourceFunction["ValueMapIndexed"][func,list] creates an association in which the values are list and keys are formed by map-indexing func over list. | |
ResourceFunction["ValueMapIndexed"][func] is an operator form of ResourceFunction["ValueMapIndexed"] that can be applied to a list. |
ValueMapIndexed with a symbolic function f applied to a list of strings:
In[1]:= |
Out[1]= |
Creates an association where each key is a hash of a value from a given list and the position of that value in the list:
In[2]:= |
Out[2]= |
ValueMapIndexed works on the first level of expressions:
In[3]:= |
Out[3]= |
It can be made to work on lower levels by using Map in conjunction with ValueMapIndexed:
In[4]:= |
Out[4]= |
ValueMapIndexed works with Query on datasets:
In[5]:= |
Out[5]= |
It also works with implicit Query operations:
In[6]:= |
Out[6]= |
Create integer row headers for the Paul Revere social network:
In[7]:= |
Out[7]= |
The resource function ValueMap is a special case of ValueMapIndexed, in which one ignores the index argument:
In[8]:= |
Out[8]= |
If a key generated from application of the function is not unique, the value for that key will be the last value encountered that generated the key:
In[9]:= |
Out[9]= |
ValueMapIndexed will not work properly on datasets without the use of Query:
In[10]:= |
Out[10]= |
Use ValueMapIndexed to create a custom index on the hash of a function of two columns of a dataset and then use the index to swiftly retrieve information:
In[11]:= |
Out[11]= |
This work is licensed under a Creative Commons Attribution 4.0 International License