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: [mg67913] Re: Question on using Table in module
  • From: dh <dh at metrohm.ch>
  • Date: Wed, 12 Jul 2006 05:39:32 -0400 (EDT)
  • References: <e92e9m$lqi$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com


Hi Nag,

Mathematica evaluates function arguments before calling a function. 

Therefore, the function sees {1,0} and you try: {1,0}[[2]]=40 what is 

0=40 and this is nonsense.

You must prevent the evaluation of the first argument, e.g. by:

SetAttributes[b, HoldFirst]



Daniel



Nag 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: Defining operators containing derivatives
  • Next by Date: Re: Q Legendre orthogonal polynomials mistake
  • Previous by thread: Re: Question on using Table in module
  • Next by thread: Re: Question on using Table in module