Re: ReplacePart

• To: mathgroup at smc.vnet.net
• Subject: [mg131639] Re: ReplacePart
• From: Bob Hanlon <hanlonr357 at gmail.com>
• Date: Sun, 15 Sep 2013 07:06:06 -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>

```{5,10} is apparently interpreted as a position within an array rather than
a list of positions. Not sure why the algorithm isn't able to resolve the
ambiguity given that the input is a simple list. Or why there is no error
stating that position {5,10} does not exist.

x = {-1.25664, 0.628319, -0.628319, 1.25664, Indeterminate, -1.25664,
0.628319, -0.628319, 1.25664, Indeterminate};

x2 = x /. Indeterminate -> 0

{-1.25664, 0.628319, -0.628319, 1.25664, 0, -1.25664, 0.628319, -0.628319, \
1.25664, 0}

x2 ==
ReplacePart[x, {5 -> 0, 10 -> 0}] ==
ReplacePart[x, Thread[{5, 10} -> 0]] ==
ReplacePart[x, {{5} -> 0, {10} -> 0}] ==
ReplacePart[x, {{5}, {10}} -> 0] ==
ReplacePart[x, List /@ {5, 10} -> 0] ==
ReplacePart[x, Position[x, Indeterminate] -> 0]

True

Bob Hanlon

On Sat, Sep 14, 2013 at 6:02 AM, man21 <man21 at free.fr> 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 ?
>
> Thanks,
>
> Michel
>
>
>

```

• Prev by Date: Re: ReplacePart
• Next by Date: constrained FindFit is extremely slow?
• Previous by thread: Re: ReplacePart
• Next by thread: Re: ReplacePart