[SciPy-user] Conditionally adding items to a list  Anne
Archibald peridot.faceted@gmail.... Tue Aug 26 11:37:48 CDT 2008
2008/8/26 Roger Herikstad <roger.herikstad@gmail.com>:  >  I
have a prolem that I was wondering if anyone could come up with
a > good solution for. I basically have to lists of number and I
want to > add elements from one list to the other as long as the
difference > between the added element and all elements already
in that list > exceeds a certain threshold. The code I came up
with is > map(times1.append,ifilter(lambda(x): >
numpy.abs(x-numpy.array(times1)).min()>1000, times2)) > but it
quickly slows down if times2 becomes sufficiently long. I need >
to be able to do this with lists of 100,000++ elements. Does
anyone > know of a quicker way of doing this?  As others have
said, you should think carefully about whether this is what you
actually want: the result you get will depend on the order of
the incoming items: [500,1000,1500] -> [500,1500]
[1000,500,1500] -> [1000]  But if it is what