Re: Replacing Values Close to One
- To: mathgroup at smc.vnet.net
- Subject: [mg105295] Re: Replacing Values Close to One
- From: dh <dh at metrohm.com>
- Date: Thu, 26 Nov 2009 06:15:04 -0500 (EST)
- References: <hekug7$921$1@smc.vnet.net>
Gregory Lypny wrote:
> Hello everyone,
>
> Is there a replacement rule that I can apply to
>
> {-8, .7, 0, 1.003} /. [what goes here?] -> 1
>
> to replace values that are close to 1, like 1.003, by 1?
>
> Regards,
>
> Gregory
>
>
>
Hi Gregory,
use a condition on a pattern:
{-8, .7, 0, 1.003} /. x_ /; Abs[x - 1] < 0.1 -> 1
Daniel