Re: Setting Negatives to Zero
- To: mathgroup at smc.vnet.net
- Subject: [mg82785] Re: Setting Negatives to Zero
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Wed, 31 Oct 2007 06:05:59 -0500 (EST)
- References: <fg6qha$dj0$1@smc.vnet.net> <fg7287$jv9$1@smc.vnet.net>
Steve Luttrell wrote:
> These do the sort of thing you want
>
> {1, 2, -3, -4, 5, 6} /. {_?(# < 0 &) -> 0}
There's one more function, Negative:
{1, 2, -3, -4, 5, 6} /. _?Negative -> 0
> {1, 2, -3, -4, 5, 6} /. {_?NonPositive -> 0}
>
> and both give
>
>