Re: Question about thread
- Subject: [mg2642] Re: Question about thread
- From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
- Date: Thu, 30 Nov 1995 21:02:40 -0500
- Approved: usenet@wri.com
- Distribution: local
- Newsgroups: wri.mathgroup
- Organization: Wolfram Research, Inc.
In article <49do38$8a6 at dragonfly.wri.com>, Scott Herod <sherod at boussinesq.Colorado.EDU> wrote: >I have a question about the way Thread behaves. From the description >in the _Mathematica_ book, I would expect it to return lists. For >example > >In[1]:= Thread[f[{a,b},x]] > >Out[1]= {f[a, x], f[b, x]} > > >But that doesn't always seem to be the case. > >In[2]:= blat[p_, q_] := Module[{}, Plus @@ (Variables[p]^q)] > >In[3]:= blat[a+b,x] > > x x >Out[3]= a + b > >In[4]:= Thread[blat[{a+c,b+d},x]] > > x x x x >Out[4]= a + b + c + d The problem you are having is that blat[{a+c,b+d}, x] is evalauting before Thread does. Try this: (Local) In[99]:= Thread[Unevaluated[blat[{a+b, c+d}, x]]] (Local) Out[99]= x x x x {a + b , c + d } Or you could change blat to do some type-checking (e.g., blat[p_?PolynomailQ,...]). Dave Wagner Principia Consulting (303) 786-8371 dbwagner at princon.com http://www.princon.com/princon