Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Question about thread

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2642] Re: Question about thread
  • From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
  • Date: Thu, 30 Nov 1995 21:02:40 -0500

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






  • Prev by Date: Re: Limiting mma caching (??)
  • Next by Date: Re; Mathematica 2.2.1 upgrade/ChemicalElements
  • Previous by thread: Re: Question about thread
  • Next by thread: Re: derivatives of indexed variables