Re: Replacing Values Close to One
- To: mathgroup at smc.vnet.net
- Subject: [mg105299] Re: Replacing Values Close to One
- From: Gregory Lypny <gregory.lypny at videotron.ca>
- Date: Fri, 27 Nov 2009 06:27:26 -0500 (EST)
- References: <hekug7$921$1@smc.vnet.net> <4B0E4C5D.5030504@metrohm.com>
Excellent, Daniel! Thank you. Still getting my head around the whole condition thing (/;). Your example is clear that the equivalent of Chop can be created easily. Regards, Gregory On Thu, Nov 26, 2009, at 4:37 AM, dh wrote: > 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 >