• To: mathgroup at smc.vnet.net
• From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
• Date: Wed, 20 Dec 2000 00:21:41 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Chris Johnson wanted to make Thread work a certain way.  Thread and many
other programming constructs in Mathematica are very versatile.  In all the
examples below any other head could have been used instead of Plus.  The
first example is the simplest way of using thread.

In[1]:=

Out[1]=
{x1+y1,x2+y2,x3+y3}

lists. That explains the result of the next example.

In[2]:=

Out[2]
{x1+h[a,b], x2+h[a,b], x3+h[a,b], x4+h[a,b]}

In the next example nothing at level 1 is a List so we have to tell the
kernel to thread over (g). We do that by giving Thread (g) as a second
argument.

In[3]:=

Out[3]=
g[x1+h[a,b], x2+h[a,b], x3+h[a,b]]

In the next case we thread over (g) but only over the first 3 occurrences of
(g).

In[4]:=

Out[4]=
g[w1+x1+y1+g[z1,z2], w2+x2+y2+g[z1,z2]]

In the next example we thread over the last 3 occurrences of (g).

In[5]:=

Out[5]=
g[x1+y1+z1+g[w1,w2], x2+y2+z2+g[w1,w2]]

Next we thread over the first occurrence through to the 2nd from the last
occurrence of (g).

In[6]:=

Out[6]=
g[w1+x1+y1+g[z1,z2], w2+x2+y2+g[z1,z2]]

-------
http://www.verbeia.com/mathematica/tips/Tricks.html

--------------------
Regards,
Ted Ersek

```

• Prev by Date: Re: physical colors and Mathematica colors