Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg125802] Re: ReplacePart, Multiple replacements in one time
  • From: nanobio9 <kuokan.liang at gmail.com>
  • Date: Tue, 3 Apr 2012 04:47:36 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jlbo41$47q$1@smc.vnet.net>

Hi,
> 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]
Just put curly braces around your list of replacements:
 a = {{1, 2}, {3, 4}}
 ReplacePart[a, {1 -> a[[1]] * 2, 2 -> a[[2]] + 5}]



  • Prev by Date: How to get this gaussian integral result?
  • Next by Date: Re: ReplacePart, Multiple replacements in one time
  • Previous by thread: ReplacePart, Multiple replacements in one time
  • Next by thread: Re: ReplacePart, Multiple replacements in one time