Re: Thread
- To: mathgroup at yoda.physics.unc.edu
- Subject: Re: Thread
- From: withoff
- Date: Tue, 23 Nov 93 12:19:18 CST
> Does anyone know why does the Thread function doesn't > allow a composed header. For example, the following > works just fine: > > In[1]:= Thread[f[g[a,b],g[c,d]],g] > > Out[1]= g[f[a, c], f[b, d]] > > In[2]:= Head[g[1][a,b]] > > Out[2]= g[1] > > In[3]:= Head[g[1][c,d]] > > Out[3]= g[1] > > But now g[1] is not recognized as an header: > > In[4]:= Thread[f[g[1][a,b],g[1][c,d]],g[1]] > > Out[4]= f[g[1][a, b], g[1][c, d]] > > > --Luis Nunes This is a previously unreported bug. Thread thinks the g[1] in f[g[1][a,b],g[1][c,d]] is not the same as the g[1] in the second argument of Thread. If you persuade Mathematica (using Share) to use the same memory location for both expressions, everything will work as intended. In[11]:= t = {f[g[1][a,b],g[1][c,d]],g[1]} Out[11]= {f[g[1][a, b], g[1][c, d]], g[1]} In[12]:= Thread @@ t Out[12]= f[g[1][a, b], g[1][c, d]] In[13]:= Thread @@ Share[t] Out[13]= g[1][f[a, c], f[b, d]] Dave Withoff Research and Development Wolfram Research