Re: need something like ReplaceAllIndexed[]
- To: mathgroup at smc.vnet.net
- Subject: [mg108485] Re: need something like ReplaceAllIndexed[]
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 19 Mar 2010 06:46:15 -0500 (EST)
- Reply-to: hanlonr at cox.net
expr = b[a[c], a[c], a[d]];
lst = {e, f, g};
Head[expr] @@ Head[expr[[1]]] /@ lst
b[a[e], a[f], a[g]]
More generally,
Inner[Head[#1][#2] &, List @@ expr, lst, Head[expr]]
b[a[e], a[f], a[g]]
Bob Hanlon
---- divisor <congruentialuminaire 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 Laboratory
http://www.youtube.com/congruentlight