MathGroup Archive 2009

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

Search the Archive

second simple problem - clarification

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99668] second simple problem - clarification
  • From: Francisco Gutierrez <fgutiers2002 at yahoo.com>
  • Date: Sun, 10 May 2009 05:19:48 -0400 (EDT)

In the problem below, I indeed found a solution. But I wonder if there is a faster/better/more elegant one.
 
My solution is:
 
posiciones2=Flatten[Position[ex,"M"]];
primerpaso=MapThread[Rule,{posiciones2,rL}];
ReplacePart[matriz2,primerpaso]
 
Thanks
Fg
 
PROBLEM
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      


  • Prev by Date: Palette Management
  • Next by Date: Re: Replace specific element with specific value.
  • Previous by thread: Re: Palette Management
  • Next by thread: Re: second simple problem - clarification