Re: need something like ReplaceAllIndexed[]
- To: mathgroup at smc.vnet.net
- Subject: [mg108492] Re: need something like ReplaceAllIndexed[]
- From: Ray Koopman <koopman at sfu.ca>
- Date: Sat, 20 Mar 2010 02:44:51 -0500 (EST)
- References: <hnva5p$88b$1@smc.vnet.net> <hnvo2b$efu$1@smc.vnet.net>
On Mar 19, 4:44 am, Ray Koopman <koop... at sfu.ca> wrote: > On Mar 19, 12:47 am, divisor <congruentialumina... at yahoo.com> wrote: >> Hello mathGroup: >> >> I have an expression like this: >> >> b[ a[c], a[c], a[d]] >> >> a list like this: >> >> {e,f,g} >> >> I want to end up with >> >> b[ a[e], a[f], a[g]] >> >> I think of this as interleaving a list into an expression, but all my >> tries with ./,.//,MapIndexed[],MapAt[], Partition[Riffle[]] have come >> to no avail. >> >> Any help on this is greatly appreciated. >> >> Roger Williams >> Franklin Laboratoryhttp://www.youtube.com/congruentlight > > In[1]:= b @@ a /@ {e,f,g} > > Out[1]= b[a[e],a[f],a[g]] Sorry, I misunderstood (oversimplified) the question. Here is the answer to a slightly more general question. In[1]:= expr = b[ a[x], c[y], d[z] ]; list = {e, f, g}; Head[expr] @@ MapThread[Head[#1][#2]&,{List@@expr,list}] Out[3]= b[ a[e], c[f], d[g] ]