MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

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



  • Prev by Date: Obtaining sequences from lists of lists
  • Next by Date: Method of line
  • Previous by thread: Re: "a[A_,B_] :=" Does not assign variables properly. Why?
  • Next by thread: Silly Mathematica button question