Filter out from a list all numbers bigger / smaller than a certain value.
Hi. Is it possible to filter out from a list all negative / all positive numbers?
And is it possible to remove all numbers bigger or smaller than a certain changeable value?
To remove a specific (relatively small) set of numbers from a list, I suggest you use [zl filter].
To remove a range of numbers (such as all negative numbers) from a list, one method is to convert the list into a stream of individual numbers with [iter], filter those numbers with [split] or [if], then reconcatenate them as a list with [thresh]. (See the caveat in this example.)
Cool! Exactly what I was looking for. Thank you very much!
vexpr ($f1<=5.) * -777777
/
t -7777777 l
/ /
zl union
/
zl slice 1 (second outlet)
/
placeholders can save you from unpacking lists
Roman, you had the right idea, but your formula was wrong (and of course this method rules out any input that matches the 'placeholder').
thanks for correction (you can tell i did that without max)
but no, i dont think -777777 will ever be greater than 5? or am i too tired now.
You're right about that. As long as one uses as a placeholder a number that will be filtered out anyway by the condition, it'll be okay.