Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: Adding value to some elements of a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131058] Re: Adding value to some elements of a list
  • From: Kurt TeKolste <ektekolste at gmail.com>
  • Date: Thu, 6 Jun 2013 07:51:50 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <komoi3$1un$1@smc.vnet.net>

I am afraid that the answer is much easier than so far offered.

Setup
In[8]:= a=10 Range[6]
Out[8]= {10,20,30,40,50,60}
In[9]:= b=2Range[3]
Out[9]= {2,4,6}

Here is what you are looking for
In[10]:= a[[b]]+=17
Out[10]= {37,57,77}


Check resultIn[11]:= a
Out[11]= {10,37,30,57,50,77}

Kurt



  • Prev by Date: Re: Applications and Packages, WRI Strikes Out!
  • Next by Date: Re: Adding value to some elements of a list
  • Previous by thread: Re: Adding value to some elements of a list
  • Next by thread: Re: Adding value to some elements of a list