Transforming numberLists 2

Daniel dealt perfectly with my first post on this topic. I now have a related question and hope the solution is just as simple. Instead of creating a new list by applying a function to all of its elements, as in N2=round(N1), is there some way to exclude elements unless they satisfy a particular condition? For example, how could I handle the case where N2 should only include even numbers from N1?

Edit: See later post for better method.

This is essentially what I was getting at in my other post. How’s this? Basically, using piecewise function notation to change list N_1, sorting it, then shortening the list.

Thanks Daniel, understood! That feels like a ‘workaround’ but perhaps a more elegant solution is in the pipeline. It is certainly good enough to achieve the effect I’m after, and the rapid response is very helpful.

I’ve been corrected. There’s an easier method. Thanks @Jay

N_2=N_1[N_1>0]

(I initially thought this would end up with NaN elements.)

1 Like

Thanks Daniel, that’s perfect!