Re: Replace and ReplaceAll -- simple application
- To: mathgroup at smc.vnet.net
- Subject: [mg105948] Re: [mg105922] Replace and ReplaceAll -- simple application
- From: "Scot T. Martin" <smartin at seas.harvard.edu>
- Date: Sun, 27 Dec 2009 02:26:27 -0500 (EST)
- References: <200912270006.TAA12080@smc.vnet.net>
The problem is that "-1." is not "1".
Also, you need to use the level specification.
In: Replace[1. (y1 - 1. yr), {1. -> 1, -1. -> -1}, Infinity]
Out: y1-yr
On Sat, 26 Dec 2009, amannuc1 wrote:
> I am doing some manipulations in Mathematica and end up with
> constructs such as "1." in the expressions. I want to convert these to
> "1" and thereby eliminate them. However, these examples don't seem to
> work. This is Mathematica 7 on OS X.
>
> In[40]:=
> Replace[1.(y1-1.yr),1.->1]
> Out[40]= 1. (y1-1. yr) (* Nothing happens *)
>
> In[39]:=
> ReplaceAll[1.(y1-1.yr),1.->1]
> Out[39]= y1-1. yr (* Only first one is replaced *)
>
> Any help is appreciated. Thanks.
>
> -Tony
>
>
- References:
- Replace and ReplaceAll -- simple application
- From: amannuc1 <Anthony.J.Mannucci@jpl.nasa.gov>
- Replace and ReplaceAll -- simple application