MathGroup Archive 2012

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

Search the Archive

Re: ReplacePart, Multiple replacements in one time

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125805] Re: ReplacePart, Multiple replacements in one time
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 3 Apr 2012 04:48:38 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 4/2/12 at 4:27 AM, andrey.demidov at gmail.com (Andrey Demidov)
wrote:

>I'm just wondering if it is possible to make n different
>replacements in one command?

>Something like this:

>>>a = {{1, 2}, {3, 4}} ReplacePart[a, 1 -> a[[1]] * 2, 2 -> a[[2]] +
>>>5]

Yes, its possible as demonstrated by:

In[3]:= a = {{1, 2}, {3, 4}};
ReplacePart[a, {1 -> 2 a[[1]], 2 -> a[[2]] + 5}]

Out[4]= {{2, 4}, {8, 9}}




  • Prev by Date: Re: ReplacePart, Multiple replacements in one time
  • Next by Date: Re: ReplacePart, Multiple replacements in one time
  • Previous by thread: Re: ReplacePart, Multiple replacements in one time
  • Next by thread: Re: ReplacePart, Multiple replacements in one time