MathGroup Archive 2006

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

Search the Archive

Re: Increment and AddTo

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64637] Re: Increment and AddTo
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Fri, 24 Feb 2006 00:19:20 -0500 (EST)
  • References: <200602221058.FAA23452@smc.vnet.net><dtjjer$det$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Sseziwa Mukasa wrote:
> [...]
> > Further:
> > i = 0;
> > v = {1, 2, 3};
> > ++v[[++i]] ;
> > v
> > i
> >
> > gives:
> > {1,2,3}
> > 2
> > Again i has been incremented by 2, but v has not been touched at all.

Both i and v change. i = the index of the changed term in v:

{i,v} = {0,{10,20,30}}; ++v[[++i]]; {i,v}

 gives  {2,{10,11,30}}

{i,v} = {1,{10,20,30}}; ++v[[++i]]; {i,v}

 gives  {3,{10,20,21}}


  • Prev by Date: Re: JLink, Double.NaN, and arrays
  • Next by Date: Re: Can't multiply non-square matrices.
  • Previous by thread: Re: Increment and AddTo
  • Next by thread: Re: Increment and AddTo