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: [mg131052] Re: Adding value to some elements of a list
  • From: Joerg Lenhardt <joerg.lenhardt at FernUni-Hagen.de>
  • Date: Thu, 6 Jun 2013 07:30:28 -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: <20130605072741.946F96A19@smc.vnet.net> <komt58$31g$1@smc.vnet.net>

Thanks to all for your support. It worked.

On 05.06.13 08:33, Adriano Pascoletti wrote:
> In[1]:= a = {10, 20, 30, 40, 50, 60};
> b = {2, 4, 6};
> a[[b]] = a[[b]] + 17;
> a
> Out[4]= {10, 37, 30, 57, 50, 77}
> 
> 
> Adriano Pascoletti
> 
> 
> 2013/6/5 Joerg Lenhardt <joerg.lenhardt at fernuni-hagen.de>
> 
>> Hello,
>>
>> I have two lists. One containing values, another containing indexes to
>> the first list. I want to add a value to all elements of the first list
>> when its index is in the second list:
>>
>> a={10,20,30,40,50,60}
>>
>> b={2,4,6}
>>
>> c=17
>>
>> ==>
>>
>> {10,20+17,30,40+17,50,60+17}
>>
>> I would be glad if anyone have a simple solution for that problem - I am
>> convinced there is one ...
>>
>> Best regards
>> J. Lenhardt
>>
>>




  • Prev by Date: Re: Rookie questions about solving for small numbers and
  • Next by Date: Re: Setting the Font Family and Font Size in BoxWhiskerChart
  • Previous by thread: Re: Adding value to some elements of a list
  • Next by thread: Re: Adding value to some elements of a list