Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #14752
| From | Adriano Pascoletti <adriano.pascoletti@uniud.it> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Adding value to some elements of a list |
| Date | 2013-06-05 08:33 +0000 |
| Message-ID | <komt58$31g$1@smc.vnet.net> (permalink) |
| References | <20130605072741.946F96A19@smc.vnet.net> |
| Organization | Time-Warner Telecom |
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@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
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Adding value to some elements of a list Adriano Pascoletti <adriano.pascoletti@uniud.it> - 2013-06-05 08:33 +0000 Re: Adding value to some elements of a list Joerg Lenhardt <joerg.lenhardt@FernUni-Hagen.de> - 2013-06-06 11:25 +0000
csiph-web