Re: "a[A_,B_] :=" Does not assign variables properly. Why?
- To: mathgroup at smc.vnet.net
- Subject: [mg36175] Re: "a[A_,B_] :=" Does not assign variables properly. Why?
- From: Rainer Gruber <rainer.gruber at gmx.at>
- Date: Mon, 26 Aug 2002 04:15:52 -0400 (EDT)
- Organization: Johannes Kepler Universitaet Linz
- References: <ak4e5f$6s$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Jason Welter wrote: > [...] Y = {A,B,C,D}; [...] > In[265]:= a[A_,B_] := LinearSolve[X,Y][[1]] > In[266]:= a[1,3] > Out[266]= -A+B > > The output above is not what I want. I want "2". > > [...] You are mixing the (global (*)) symbols A and B with the (local (*)) patterns A_ and B_. If you want to replace the (global) solution with local values you should write In[4]:= a[AA_, BB_] := LinearSolve[X, Y][[1]] /. {A -> AA, B -> BB}; a[1, 3] Out[5]= 2 ________________ (*) as far we can say that in Mathematica -- Rainer Gruber