MathGroup Archive 2001

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

Search the Archive

Re: Thread and MapThread

  • To: mathgroup at
  • Subject: [mg29870] Re: Thread and MapThread
  • From: "Allan Hayes" <hay at>
  • Date: Sun, 15 Jul 2001 00:58:58 -0400 (EDT)
  • References: <9iomi4$i17$>
  • Sender: owner-wri-mathgroup at


Here are the relevant evaluation steps of
Thread[ftest[{x1, x2, x3}, {y1, y2, y3}]]

       Thread[ {f1[{x1, x2, x3}], f2[{y1, y2, y3}]}]
(*ftest[...] evaluates before Thread acts*)

       {f1[{x1, x2, x3}], f2[{y1, y2, y3}]}]
(*Thread does nothing since it has not, for example, been told to thread
over f1}*)



        f1[{{x1, x2, x3}, f2[{y1, y2, y3}]}]

There are many ways of avoiding premature evaluation, here are a few

Thread[Unevaluated[ftest[{x1,x2,x3},{y1,y2,y3}]]] (*caution:x1, ... are

        {{f1[x1], f2[y1]}, {f1[x2], f2[y2]}, {f1[x3], f2[y3]}}


        {{f1[x1], f2[y1]}, {f1[x2], f2[y2]}, {f1[x3], f2[y3]}}


{{f1[x1], f2[y1]}, {f1[x2], f2[y2]}, {f1[x3], f2[y3]}}

Allan Hayes
Mathematica Training and Consulting
Leicester UK
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"David Park" <djmp at> wrote in message
news:9iomi4$i17$1 at
> Dear MathGroup,
> Here is a function:
> ftest[x_, y_] := {f1[x], f2[y]}
> Why does the following work...
> MapThread[ftest, {{x1, x2, x3}, {y1, y2, y3}}]
> {{f1[x1], f2[y1]}, {f1[x2], f2[y2]}, {f1[x3], f2[y3]}}
> ...but the following does not work.
> Thread[ftest[{x1, x2, x3}, {y1, y2, y3}]]
> {f1[{x1, x2, x3}], f2[{y1, y2, y3}]}
> David Park
> djmp at

  • Prev by Date: Re: 1) Numerical precision, 2) Bug in Plot?
  • Next by Date: Exponents and notation
  • Previous by thread: Re: Thread and MapThread
  • Next by thread: Re: Re: Thread and MapThread