Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15453 > unrolled thread

Re: ReplacePart

Started byBob Hanlon <hanlonr357@gmail.com>
First post2013-09-15 11:04 +0000
Last post2013-09-15 11:04 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: ReplacePart Bob Hanlon <hanlonr357@gmail.com> - 2013-09-15 11:04 +0000

#15453 — Re: ReplacePart

FromBob Hanlon <hanlonr357@gmail.com>
Date2013-09-15 11:04 +0000
SubjectRe: ReplacePart
Message-ID<l1448m$psq$1@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@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
>
>
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web