MathGroup Archive 2010

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

Search the Archive

Re: need something like ReplaceAllIndexed[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108488] Re: need something like ReplaceAllIndexed[]
  • From: rafscipio <scipionedalferro at yahoo.it>
  • Date: Fri, 19 Mar 2010 06:46:49 -0500 (EST)
  • References: <hnva5p$88b$1@smc.vnet.net>

On 19 Mar, 08:47, 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

Hi,

here is a way:

In[1]:= x = b[a[c], a[c], a[d]];

In[2]:= y = {e, f, g};

In[3]:= Do[x[[i, 1]] = y[[i]], {i, 3}]; x

Out[3]= b[a[e], a[f], a[g]]


Scipione.


  • Prev by Date: Re: need something like ReplaceAllIndexed[]
  • Next by Date: Re: need something like ReplaceAllIndexed[]
  • Previous by thread: Re: need something like ReplaceAllIndexed[]
  • Next by thread: Re: need something like ReplaceAllIndexed[]