Re: second simple problem
- To: mathgroup at smc.vnet.net
- Subject: [mg99701] Re: [mg99667] second simple problem
- From: Adriano Pascoletti <adriano.pascoletti at dimi.uniud.it>
- Date: Mon, 11 May 2009 06:27:04 -0400 (EDT)
- References: <200905100919.FAA10179@smc.vnet.net>
Francisco,this solution can be easily generalized
In[8]:= ex = {1, 5, 7, 4, "M", 6, 7, 8, 9, 1, "M", 3};
vals = {5, 2};
i = 1;
ex /. "M" :> vals[[i++]]
Out[11]= {1, 5, 7, 4, 5, 6, 7, 8, 9, 1, 2, 3}
Adriano Pascoletti
2009/5/10 Francisco Gutierrez <fgutiers2002 at yahoo.com>
> Dear sirs:
> I have the following list:
> ex={1,5,7,4,"M",6,7,8,9,1,"M",3}
> I want to replace the M's in the following way: the first M by 5, and the
> second by2.
> Thus I have a replacement list
> rL={5,2}
> The problem is to get ={1,5,7,4,5,6,7,8,9,1,2,3}
> How can I do this in the most general form (for any length of ex and any
> number of values of "M")?
> Thanks
> Francisco
>
>
- References:
- second simple problem
- From: Francisco Gutierrez <fgutiers2002@yahoo.com>
- second simple problem