MathGroup Archive 2005

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

Search the Archive

Re: Threading 'Append'


On 6 Dec 2005, at 03:40, J Siehler wrote:

> If I run
>
> Thread[Append[{{1,2},{3,4},{5,6}},{a,b,c}]]
>
> I would expect to get
>
> {{1,2,a},{3,4,b},{5,6,c}}
>
> but in fact I get an 'Objects of unequal length' error.
>
> On the other hand,
>
> Thread[foo[{{1,2},{3,4},{5,6}},{a,b,c}]]
> %/.foo->Append
>
> gives what I wanted.  Can someone explain what's going on?
>

All you need to do is:

In[9]:=
Thread[Unevaluated[Append[{{1, 2}, {3, 4}, {5, 6}},
     {a, b, c}]]]

Out[9]=
{{1, 2, a}, {3, 4, b}, {5, 6, c}}


The name of the function "Unevaluated" should make it self evident  
what happened here (I hope).

Andrzej Kozlowski


  • Prev by Date: Re: Types in Mathematica, a practical example
  • Next by Date: Can you solve my gravity-maths problem in Mathematica?
  • Previous by thread: Threading 'Append'
  • Next by thread: Re: Re: Threading 'Append'