Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate an association from applying different operations to an expression
ResourceFunction["AssociationThrough"][{f1,f2,…},x] gives <|f1→f1[x],f2→f2[x],…|>. | |
ResourceFunction["AssociationThrough"][{f1→label1,f2→label2,…},x] gives <|label1→f1[x],label2→f2[x],…|>. | |
ResourceFunction["AssociationThrough"][f] represents an operator form of ResourceFunction["AssociationThrough"] that can be applied to an expression. |
Generate an Association to label the results of different operations on an expression:
In[1]:= |
|
Out[1]= |
|
Give the operations labels:
In[2]:= |
|
Out[2]= |
|
Perform multiple statistical operations on a single distribution, returning a single expression:
In[3]:= |
|
Out[3]= |
|
Adding bulletproofing to statistical operations complicates the keys of the resulting expression:
In[4]:= |
|
Out[4]= |
|
Use a more appropriate label to hide the complications in the result:
In[5]:= |
|
Out[5]= |
|
Use an operator form to be applied to many expressions:
In[6]:= |
|
In[7]:= |
|
Out[7]= |
|
Use formatted names as labels and show in a grid:
In[8]:= |
|
Out[8]= |
|
Write a function to generate a simple association of statistical information that is robust to unclean data:
In[9]:= |
|
In[10]:= |
|
Out[10]= |
|
Values can be extracted using simple keys:
In[11]:= |
|
Out[11]= |
|
AssociationThrough is similar to a special case of AssociationMap:
In[12]:= |
|
Out[12]= |
|
AssociationThrough can give different labels for the keys:
In[13]:= |
|
Out[13]= |
|
A similar operation can be done with a combination of AssociationThread and Through:
In[14]:= |
|
Out[14]= |
|
If there are duplicate operations, all but the last is dropped:
In[15]:= |
|
Out[15]= |
|
If there are duplicate labels, all but the last is dropped:
In[16]:= |
|
Out[16]= |
|
This work is licensed under a Creative Commons Attribution 4.0 International License