Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Question on Thread

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64418] Question on Thread
  • From: "Matt" <anonmous69 at netscape.net>
  • Date: Thu, 16 Feb 2006 03:05:29 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,

Clear[f]
Thread[(f[#1, #2] & )[{1, 2, 3}, {{a, 1}, {b, 2}, {c, 3}}]]

Gives the expected output, i.e. {f[1,{a,1}], f[2,{b,2}],...}

but

Clear[f, g]
Thread[(f[g[#1], #2] & )[{1, 2, 3}, {{a, 1}, {b, 2}, {c, 3}}]]

gives me:

f[g[{1, 2, 3}], {a, 1}], f[g[{1, 2, 3}], {b, 2}], ..., etc.

whereas I would have expected:

f[g[1], {a, 1}], f[g[2], {b, 2}], ..., etc.

I've looked at the 'Thread' documentation and in the Mathematica Book,
but I can't see why the second case doesn't work.

BTW, I used MapThread as follows, which does work:

MapThread[f[g[#1], #2] & , {{1, 2, 3}, {{a, 1}, {b, 2}, {c, 3}}}

Thanks for your time,

Matt


  • Prev by Date: Set function
  • Next by Date: Re: Using a text editor like interface for Mathematica?
  • Previous by thread: Re: Set function
  • Next by thread: Re: Question on Thread