Re: ReplacePart

• To: mathgroup at smc.vnet.net
• Subject: [mg131644] Re: ReplacePart
• From: Itai Seggev <itais at wolfram.com>
• Date: Sun, 15 Sep 2013 07:07:47 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net
• References: <20130914100259.8EA2C6A1A@smc.vnet.net>

```On Sat, Sep 14, 2013 at 06:02:59AM -0400, man21 wrote:
> Hello,
>
> As a result of a calculation, I end up with a list of numerical values
> which contains  some "Indeterminate".
>
> x ={-1.25664, 0.628319, -0.628319, 1.25664, Indeterminate, -1.25664,
> 0.628319, -0.628319, 1.25664, Indeterminate}
>
> I try to replace the "Indeterminate" by "0", using :
>
> ReplacePart[x, {5, 10} -> 0.]
>
> but this dosen't work. Any idea why, and how to do it ?

A flat list in ReplacePart is interpreted as a single multi-level part
specification.  For example,

In[282]:= ReplacePart[Array[a, {2, 2}], {1, 2} -> 0.]

Out[282]= {{a[1, 1], 0.}, {a[2, 1], a[2, 2]}}

What you want is this.

In[280]:= ReplacePart[x, {{5}, {10}} -> 0.]

Out[280]= {-1.25664, 0.628319, -0.628319, 1.25664, 0., -1.25664, \
0.628319, -0.628319, 1.25664, 0.}

I think in any event it is easier and better to use ReplaceAll

In[283]:= x /. Indeterminate -> 0.

Out[283]= {-1.25664, 0.628319, -0.628319, 1.25664, 0., -1.25664, \
0.628319, -0.628319, 1.25664, 0.}

--
Itai Seggev
Mathematica Algorithms R&D
217-398-0700

```

• Prev by Date: Re: multiintegral and table
• Next by Date: very odd failure of Solve
• Previous by thread: Re: ReplacePart
• Next by thread: Re: ReplacePart