MathGroup Archive 2006

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

Search the Archive

Re: Question on using Table in module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67926] Re: [mg67894] Question on using Table in module
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Thu, 13 Jul 2006 06:53:28 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

Inside your module, x had the value {0,1} not the Symbol a. You want the first argument to be held

SetAttributes[b, HoldFirst];
b[x_,n_,d_]:=Module[{},x[[n]]=d]; 

a = {1, 0} ;
b[a,2,40];
a

{1,40}


Bob Hanlon

---- Nag <Naga1010 at gmail.com> wrote: 
> Hello:
> 
> Look at the following code fragment.
> 
> a = {1, 0}
> b[x_,n_,d_]:=Module[{i},x[[n]]=d];
> b[a,2,40]
> 
> ?a
> a = {1, 0}
> 
> Executing gives the error message:
> Set::setps: {1, 0} in assignment of part is not a symbol.
> 
> I followed the link to the Help browser, but do not understand the
> explanation.
> 
> What is happening here? Please help.
> 
> Best
> Nag
> 


  • Prev by Date: Re: List Question
  • Next by Date: Re: List Question
  • Previous by thread: Re: Question on using Table in module
  • Next by thread: Re: Question on using Table in module