Function Repository Resource:

# ThroughOperator

An operator that applies multiple functions to one set of arguments

Contributed by: Sjoerd Smit
 ResourceFunction["ThroughOperator"][{f1,f2,…}][arg1,arg2,…] returns {f1[arg1,arg2,…],f2[arg1,arg2,…],…}. ResourceFunction["ThroughOperator"][{f1,f2,…}, h][args,…] returns h[f1[args,…],f2[args,…],…]. ResourceFunction["ThroughOperator"][<|key1→f1,key2→f2,…|>][args,…] returns <|key1→f1[args,…],key2→f2[args,…],…|>.

## Details

ResourceFunction["ThroughOperator"] is an alternative to Through that is easy to use as an operator and also works with an Association of functions.
ResourceFunction["ThroughOperator"] works with heads other than List in the first argument.

## Examples

### Basic Examples (2)

Apply a list of functions to some arguments:

 In[1]:=
 Out[1]=

ThroughOperator can be mapped easily:

 In[2]:=
 Out[2]=
 In[3]:=
 Out[3]=

### Scope (4)

ThroughOperator works with other heads as well:

 In[4]:=
 Out[4]=

Define an operator that generates an Association with function values:

 In[5]:=
 Out[5]=

Compute a number of Booleans for a number; use And to test if they are all True:

 In[6]:=
 Out[6]=

This can be achieved with the two-argument form as well:

 In[7]:=
 Out[7]=

Note that only the necessary functions are evaluated:

 In[8]:=
 Out[8]=
 In[9]:=
 Out[9]=

The two-argument form of ThroughOperator is convenient for functions that would evaluate prematurely in the one-argument form:

 In[10]:=
 Out[12]=
 In[13]:=
 Out[13]=

Other functions will work correctly in the one-argument form but will issue messages:

 In[14]:=
 Out[14]=

These messages can be avoided with the two-argument form:

 In[15]:=
 Out[15]=

Sjoerd Smit

## Version History

• 1.0.1 – 19 December 2022
• 1.0.0 – 13 December 2022