Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create a list of positive integers containing as many elements as the expression to which it is applied
ResourceFunction["CorrespondingIntegers"][expr] gives a List {1…n} of positive integers where n is the length of expr. | |
ResourceFunction["CorrespondingIntegers"][expr,start,jump] gives a list {start,start+jump,…,start+(n-1)×jump} where n is the length of expr. | |
ResourceFunction["CorrespondingIntegers"][start,jump] creates an operator that, when applied to an expression expr, gives a list {start,start+jump,…,start+(n-1)×jump} where n is the length of expr. |
Create a List of the positive integers corresponding to letters "a" to "j":
In[1]:= |
Out[1]= |
Create a list of integers starting with 5 and incrementing by 2 each time that correspond to the letters "a" to "j":
In[2]:= |
Out[2]= |
Create an operator which, when applied to an expression, creates a list with the same number of parts as that expression in which the first element is 1 and each successive value is 1 higher:
In[3]:= |
Out[3]= |
The function works on expressions that are not lists:
In[4]:= |
Out[4]= |
Because the length of an Association is equal to its number of key value pairs, the function can be sensibly applied to associations:
In[5]:= |
Out[5]= |
The function looks only at the first level of an expression to determine the correspondence:
In[6]:= |
Out[6]= |
Using non-integer values for the starting value and/or the jump will give a warning, as this is not the purpose for which the function is intended:
In[7]:= |
Out[7]= |
Use CorrespondingIntegers to develop indices into a training and test set used for machine learning:
In[8]:= |
Out[8]= |
Index the terms in some document both backward and forward:
In[9]:= |
Out[9]= |
This function can be combined with Thread to emulate the action of MapIndexed at level 1, where one takes the first part of the index:
In[10]:= |
Out[10]= |
This work is licensed under a Creative Commons Attribution 4.0 International License