Re: Q: efficient list operation wanted

*To*: mathgroup at smc.vnet.net*Subject*: [mg13995] Re: [mg13973] Q: efficient list operation wanted*From*: Wouter Meeussen <eu000949 at pophost.eunet.be>*Date*: Sat, 12 Sep 1998 16:59:18 -0400*Sender*: owner-wri-mathgroup at wolfram.com

try L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} Fold[ReplacePart[#1,#2,First at Position[#1,3]] & ,L1, L2] wouter. ******************************* At 15:07 11-09-98 -0400, Klaus Duellmann wrote: >I am looking for an efficient solution of the following problem: > >Given two lists L1 = {1,2,3,4,5,3,7,2,3,9} and L2 = {a, b, c} > >I want to replace all numbers 3 in L1 by the elements of L2 >successively, >that is the first 3 by a, the second 3 by b and the third 3 by c. That >is I want to get the following modified L1-list: {1,2,a,4,5,b,7,2,c,9}. > >Replace[] unfortunately replaces elements with a single element only. Is >there a chance to avoid hideous Do-Loops? > >Any hints are appreciated! > >PS. Remove XXX from my e-mail-address > >K. Duellmann > > Dr. Wouter L. J. MEEUSSEN w.meeussen.vdmcc at vandemoortele.be eu000949 at pophost.eunet.be