|
[Date Index]
[Thread Index]
[Author Index]
Better Way of Testing and Replacing List Elements?
- To: mathgroup at smc.vnet.net
- Subject: [mg103949] Better Way of Testing and Replacing List Elements?
- From: careysub <careysub at gmail.com>
- Date: Tue, 13 Oct 2009 23:19:52 -0400 (EDT)
The code below replaces the negative values in a list with zero, and
is an example of a type of operation I use a lot:
xxx = {1, 2, 3, 4, 5, -6, -7, 8, 9, 10, -1, 11, 12};
ReplacePart[xxx, Position[Map[Negative, xxx], True] -> 0]
Is there a "better" way of doing this (fewer function calls, more
efficient)?
My feeling is that I'm doing this in an awkward way.
Prev by Date:
Re: generating submultisets with repeated elements
Next by Date:
Re: Mathematica 7.01 and Mac OS 10.6 (Snow Leopard)
Previous by thread:
Re: On ~= (simulating a C structure) in Mathematica....
Next by thread:
Re: Better Way of Testing and Replacing List Elements?
|