Re: Threading 'Append'
- To: mathgroup at smc.vnet.net
- Subject: [mg62811] Re: [mg62796] Threading 'Append'
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Tue, 6 Dec 2005 00:03:06 -0500 (EST)
- References: <200512051840.NAA21108@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Dec 5, 2005, at 1:40 PM, 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? It's an evaluation order problem Thread[Unevaluated[Append[{{1, 2}, {3, 4}, {5, 6}}, {a, b, c}]]] works. I've run into this problem before, it's even worse if you try to do l1 = {{1, 2}, {3, 4}, {5, 6}}; l2 = {a, b, c}; Thread[Unevaluated[Append[l1, l2]]] Most of the time I just work around it with MapThread which evaluates the expressions in the order one would prefer. Regards, Ssezi
- References:
- Threading 'Append'
- From: "J Siehler" <jsiehler@Gmail.com>
- Threading 'Append'