Re: Questions on Apply function
- To: mathgroup at smc.vnet.net
- Subject: [mg62908] Re: Questions on Apply function
- From: "dkr" <dkrjeg at adelphia.net>
- Date: Thu, 8 Dec 2005 00:05:08 -0500 (EST)
- References: <dn5ogd$nks$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Out[1] and Out[3] are consistent. In the second argument of In[2], you are adding b to b1, while in In[1] you are adding b to a1. The problem seems to be that your pure function is a function of one variable, but you are evaluating it with 2 arguments, which means the second argument will be ignored. After evaluating Apply, In[1] becomes {#+{-6750,6435}&[6945,-4545],#+{-6750,6435}&[6945, -4545]}. Now look at the second argument of the outermost list: # will assume the value 6945, the value -4545 will be ignored, and you end up with the result 6945+{-6750,6435}. Thus Mathematica will add 6945 to each number in the list, yielding {195,13380}. Your comment regarding In[2] suggests that what you really want to do is: In[20]:= Apply[({#1,#2}+{a,b})&,{{a1,b1},{a2,b2},{a3,b3}},{1}] Out[20]= {{a+a1,b+b1},{a+a2,b+b2},{a+a3,b+b3}}