Re: Questions on Apply function
- To: mathgroup at smc.vnet.net
- Subject: [mg62907] Re: [mg62866] Questions on Apply function
- From: "David Park" <djmp at earthlink.net>
- Date: Thu, 8 Dec 2005 00:05:01 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I don't think you really want Apply. You want function application. Try
this.
{{6945, -4545}, {6945, -4545}};
# + {-6750, 6435} & /@ %
{{195, 1890}, {195, 1890}}
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: PengYu.UT at gmail.com [mailto:PengYu.UT at Gmail.com]
To: mathgroup at smc.vnet.net
Please look at the following code. I'm wondering the output 1 doesn't
give me the right answer. 6435-4545 should be 1890. Is there anything
wrong with input 1? It seems that it is correct, because input 3 works
well.
Thanks,
Peng
In[1]:=
Apply[(#+{-6750,6435})&,{{6945,-4545},{6945, -4545}},{1}]
Out[1]=
{{195,13380},{195, 13380}}
In[2]:=
{-6750,6435}+{6945,-4545}
Out[2]=
{195,1890}
In[3]:=
Apply[(#+{a,b})&,{{a1,b1},{a2,b2},{a3,b3}},{1}]
Out[3]=
{{a+a1,a1+b},{a+a2,a2+b},{a+a3,a3+b}}