Mathematica 9 is now available
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

Re: Problem with Thread over Plus?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65388] Re: [mg65370] Problem with Thread over Plus?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Thu, 30 Mar 2006 05:29:39 -0500 (EST)
  • References: <200603291134.GAA27493@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

> On 29 Mar 2006, at 13:34, Virgilio, Vincent - SSD wrote:
>
> Hello,
>
> Why does this work:
>
> 	Thread[ Plus[ {1,1} , { {1,1} , {2,2} } ] ]
>
> but this doesn't?
>
> 	Thread[ Plus[ {1,1} , { {1,1} , {2,2} , {3,3} } ] ]
>
> Thanks,
>
> Vince Virgilio
>
>

Thread evaluates its argument(s) so in the first case you get the  
equivalent of this


Plus[{1, 1}, {{1, 1}, {2, 2}}]


{{2, 2}, {3, 3}}


Thread[%]


{{2, 3}, {2, 3}}

while in the second

Plus[ {1, 1} , { {1, 1} , {2, 2} , {3, 3} } ]

tries to add lists of different lengths and fails.

In fact, are you sure that you really meant to get the answer you did  
get in the case you claim "works"? Did you not rather mean this:


Thread[Unevaluated[Plus[{1, 1} , {{1, 1}, {2, 2}}]]]


{{2, 2}, {3, 3}}


?


It is a little harder to make the second case work in the same way  
but of course it can be done:


Thread[ Unevaluated[Plus[ {1,1} , { {1,1} , {2,2} , {3,3} } ] ],List,-1]


{{2, 2}, {3, 3}, {4, 4}}


Andrzej Kozlowski






  • Prev by Date: Re: solving
  • Next by Date: Re: Two independent y axes ?
  • Previous by thread: Re: Problem with Thread over Plus?
  • Next by thread: Re: Problem with Thread over Plus?