Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Perform a folding operation parsing multiple arguments
ResourceFunction["FoldThread"][f,x ,{{a1,a2,…},{b1,b2,…},…}] gives the last element of ResourceFunction["FoldThreadList"][f,x,{{a1,a2,…},{b1,b2,…},…}]. | |
ResourceFunction["FoldThread"][f,{{a1,a2,…},{b1,b2,…},…}] gives ResourceFunction["FoldThread"][f,{a1,b1,…},{{a2,…},{b2,…},…}]. | |
ResourceFunction["FoldThread"][f] represents an operator form of ResourceFunction["FoldThread"] that can be applied to expressions. |
Use FoldThread to fold a function over lists, threading the elements:
In[1]:= |
Out[1]= |
Without an initializer, the first element of each list is the initializer:
In[2]:= |
Out[2]= |
Make an operator:
In[3]:= |
Use the operator, feeding in a list of lists:
In[4]:= |
Out[4]= |
Integrate the function f(x,y,z)=x+y+z as x ranges from 0 to 2, y from 0 to 2, and z from 0 to 2:
In[5]:= |
Out[5]= |
Create a continued fraction with different numerators:
In[6]:= |
Out[6]= |
Fold and FoldThread give equivalent results for the case in which a single argument is folded:
In[7]:= |
Out[7]= |
This work is licensed under a Creative Commons Attribution 4.0 International License