Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9378

Re: ReplacePart, Multiple replacements in one time

From nanobio9 <kuokan.liang@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: ReplacePart, Multiple replacements in one time
Date 2012-04-03 08:49 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jledjl$h0k$1@smc.vnet.net> (permalink)
References <jlbo41$47q$1@smc.vnet.net>

Show all headers | View raw


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}]

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

ReplacePart, Multiple replacements in one time Andrey Demidov <andrey.demidov@gmail.com> - 2012-04-02 08:30 +0000
  Re: ReplacePart, Multiple replacements in one time nanobio9 <kuokan.liang@gmail.com> - 2012-04-03 08:49 +0000
  Re: ReplacePart, Multiple replacements in one time Rodrigo Murta <murta@rodrigomurta.com> - 2012-04-03 08:54 +0000

csiph-web