Re: Functions with vector arguments
- To: mathgroup at smc.vnet.net
- Subject: [mg36235] Re: Functions with vector arguments
- From: "ET" <ed.toussieh at worldet.att.net>
- Date: Tue, 27 Aug 2002 02:08:00 -0400 (EDT)
- References: <akcpm8$557$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
I do not know why you are getting a message, using your own code I get the result you expect. "anhjunk" <anhjunk at hotmail.com> wrote in message news:akcpm8$557$1 at smc.vnet.net... > Some functions with vector arguments work as expected and some give > errors. I would appreciate if someone can clarify why. > > First an example of a function definition that works fine : > f[u_,v_] := u.v > Calling it with f[{x1,y1},{x2,y2}] gives the expected result x1 x2 + > y1 y2. > > Now an example that does not work : > g[u_,v_] := u-v > Calling it with g[{x1,y1},{x2,y2}] one would expect the answer {x1-x2, > y1-y2} but instead one gets error messages. > > Why ? And how do I fix g (i.e write a function that outputs the > difference of 2 vectors). > > Thanks >