Removing elements from a list based on condition

Pvdn's icon

I am breaking my head on how to remove certain elements form a list (zeros in this case). I tried to do a zl.iter, into a select 0, and then catching all non-matching values in to a zl.group. The thing is that the zl.group needs to know beforehand how many elements to group. What's the best way to approach this?

Related question 1: if i want to add a value to every value-item in a list, is there a better way than to do a zl.iter, followed by a +, followed by a zl.group? It seems overly complicated.

Related question 2: I'm dealing with incoming midi-data, how bad is it (timingwise) to handle things like the above with a simple js function (with immediate set to 1)? I could solve stuff like this easily by code, but i am wondering if it's a good idea to step outside of the native objects when timing is critical.

Rick's icon

Have you looked at zl.filter and vexpr?

Max Patch
Copy patch and select New From Clipboard in Max.

Pvdn's icon

Thanks! That sure helps a lot :)