This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Programming / Functional Programming  /
Thread

  • Thread[ f [ args ]] "threads" f over any lists that appear in args.
  • Thread[ f [ args ], h ] threads f over any objects with head h that appear in args.
  • Thread[ f [ args ], h , n ] threads f over objects with head h that appear in the first n args.
  • Thread[ f [ args ], h , - n ] threads over the last n args.
  • Thread[ f [ args ], h , m , n ] threads over arguments m through n.
  • Example: Thread[f[ a,b , c, d,e ]].
  • Functions with attribute Listable are automatically threaded over lists.
  • All the elements in the specified args whose heads are h must be of the same length.
  • Arguments that do not have head h are copied as many times as there are elements in the arguments that do have head h.
  • Thread uses the standard sequence specification (see Section A.3.5).
  • See the Mathematica book: Section 2.2.10.
  • See also: Distribute, Map, Inner, MapThread.

    Further Examples

    In[1]:=

    Out[1]=

    The Log function threads over lists but not over equations.

    In[2]:=

    Out[2]=

    In[3]:=

    Out[3]=

    You can use Thread to get functions applied to both sides of an equation.

    In[4]:=

    Out[4]=