Function Repository Resource:

# AssociationThrough

Generate an association from applying different operations to an expression

Contributed by: Andrew Steinacher
 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.

## Details and Options

ResourceFunction["AssociationThrough"][{f1,f2,},x] is equivalent to AssociationMap[#[x]&,{f1,f2}].

## Examples

### Basic Examples (2)

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]=

### Scope (2)

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]=

### Applications (3)

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]=

### Properties and Relations (3)

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]=

### Possible Issues (2)

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]=

## Publisher

Andrew Steinacher

## Version History

• 1.0.0 – 31 August 2020

## Author Notes

Although combinations of AssociationThread, Through, AssociationMap and similar can achieve this same effect, it's difficult to remember how to use them in this fashion. It's even more difficult to handle complicated operations while generating "nice" labels in a clean, concise and robust way… these two problems occur frequently enough for this function to be useful.