ReplacePart question
- To: mathgroup at smc.vnet.net
- Subject: [mg13065] ReplacePart question
- From: walter-seaman at uiowa.edu (Walter Seaman)
- Date: Sat, 4 Jul 1998 16:45:06 -0400
- Organization: The University of Iowa
- Sender: owner-wri-mathgroup at wolfram.com
hello, Here is what m'ca ReplacePart is supposed to do according to the online help and the manual: "ReplacePart[expr, new, pos, npos] replaces parts at positions pos in expr by parts at positions npos in new." For example: ReplacePart[{a, b, c,d},{x,y},{{1},{4}},2] gives output {y,b,c,y} which is ok. I cannot get m'ca to replace selected parts of expr with selected parts of new. 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 {{x,y}\[LeftDoubleBracket]2,1\[RightDoubleBracket],b, 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 {{x,y}\[LeftDoubleBracket]{2},{1}\[RightDoubleBracket],b, c,{x,y}\[LeftDoubleBracket]{2},{1}\[RightDoubleBracket]} Can anyone tell me how to accomplish this selective replacement? Thanks, W.Seaman