MathGroup Archive 1997

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

Search the Archive

ReplacePart

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9656] ReplacePart
  • From: bmarks at helix.nih.gov (William B. Marks)
  • Date: Mon, 17 Nov 1997 19:50:16 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Under "Help" in Mathematica 3.0.1 it says ReplacePart[expr, new, pos,
npos] replaces parts at positions pos in expr by parts at positions
npos in new.

When I try
ReplacePart[{1,2,3,4,5},{7,8},{{2},{3}}, {1}] I get
{1,7,7,4,5}

But when I try to put parts 1 and 2 in parts 2 and 3 it fails
ReplacePart[{1,2,3,4,5}, {7,8}, {{2},{3}}, {1,2}] Or
ReplacePart[{1,2,3,4,5}, {7,8}, {{2},{3}}, {{1},{2}}] I get
"Part specification {7,8}[[1,2]]  (or {7,8}[[{1},{2}]] ) is longer than
depth of object"

So it appears I have to use Fold to replace several parts of expr1 with
corresponding parts or expr2.

What do you think?




  • Prev by Date: Good Day
  • Next by Date: Re: [mg9568}Color Printing -- Thanks
  • Previous by thread: Re: Good Day
  • Next by thread: Re: ReplacePart