Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: ReplacePart question

  • To: mathgroup at
  • Subject: [mg13100] Re: ReplacePart question
  • From: "Paul A. Rombouts" <paromb at>
  • Date: Tue, 7 Jul 1998 03:44:06 -0400
  • Organization: World Online
  • References: <6nkvd3$>
  • Sender: owner-wri-mathgroup at

Walter Seaman wrote in message <6nkvd3$17k at>...

>For example, suppose I want to take the list
>{a,b,c,d} and replace a with y and x with b.  It seems I should be able
>to use the command
>ReplacePart[{a, b, c,d},{x,y},{{1},{4}},{2,1}]
>but the output is
>  c,{x,y}\[LeftDoubleBracket]2,1\[RightDoubleBracket]}
>i.e. m'ca is looking for {x,y}[[1,2]] (which is not defined) and trying
>to replace it in positions 1 and 4.
>If I try
>ReplacePart[{a, b, c,d},{x,y},{{1},{4}},{{2},{1}}]
>I still get the output
>  c,{x,y}\[LeftDoubleBracket]{2},{1}\[RightDoubleBracket]}
>Can anyone tell me how to accomplish this selective replacement? Thanks,

Hello Walter,

I've encountered exactly the same problem some months ago and I've
complained to student-support at Wolfram Research about it. I think
their reply might also be of interest to you:

From: "Paul A. Rombouts" <paromb at> To:
mathgroup at
Subject: [mg13100] unexpected failure of ReplacePart


I use Mathematica for Students v3.0.0.0 under Windows NT 4.0 on a
Pentium PC.
Please consider the following Mathematica in- and output:

In[1]:= ReplacePart[{a,b,c},{d,e,f},{{1},{2}},{{2},{3}}]

    "Part specification {d, e, f}[[{2},{3}]] is longer than depth of

Out[1]= {{d,e,f}[[{2},{3}]],{d,e,f}[[{2},{3}]],c}

After reading the description of ReplacePart in appendix A.10 of the
Mathematica book 3rd edition, page 1183, I expected the result to be
{e,f,c}. Did I misinterpret the manual or could it be that the present
implementation of ReplacePart does not conform to its specification?

Kind regards,

Paul A. Rombouts <paromb at>

Hello Paul,

What you want to do is not possible in V3.0.x.  You will have to replace
the parts individually and use a sequence of ReplaceParts commands:

In[51]:= ReplacePart[{a,b,c},{d,e,f},1,2] Out[51]= {e,b,c}

I have been told that the ablility to replace multiple parts will be
available in the next major release (i.e. 3.1).

Tom Zeller
Wolfram Research Technical Support - Student Versions


  • Prev by Date: Re: Getting a bitmap to display with the proper dimensions
  • Next by Date: RE: logical inconsistency in U
  • Previous by thread: Re: Re: ReplacePart question
  • Next by thread: Re: ReplacePart question