MathGroup Archive 2013

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

Search the Archive

Re: Adding value to some elements of a list


If you want to do it in place, then:

In[1]:= a[[b]] += c;
In[2]:= a
Out[2]= {10, 37, 30, 57, 50, 77}

> 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: Adding value to some elements of a list
  • Next by Date: Re: fyi, making animation into PDF file from images genenerated by Mathematica
  • Previous by thread: Re: Adding value to some elements of a list
  • Next by thread: Unexpected expectation behaviour