Forums > MaxMSP

removing the first 0s in a list …


Feb 10 2011 | 8:15 am

Hi max users,

How do I remove the first seven 0s in this list (while keeping the rest of the 0s of course):

0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Thanks for your help!

ana


pid
Feb 10 2011 | 8:28 am

-- Pasted Max Patch, click to expand. --

Feb 10 2011 | 8:32 am

ok, yes, zl slice works in this case, but what if he amount of 0s in the beginning is variable?

Something like:

See the beginning of the list, remove all 0s until there is a non 0 value, keep the rest.

Feb 10 2011 | 9:47 am

-- Pasted Max Patch, click to expand. --

Feb 10 2011 | 11:56 am

Or without recursion


-- Pasted Max Patch, click to expand. --

Feb 10 2011 | 12:03 pm

However


-- Pasted Max Patch, click to expand. --

Feb 10 2011 | 1:29 pm

@jkvr: nice! Recursion rules :-)

Feb 10 2011 | 4:53 pm

While this looks nice, I would recommend staying away from the recursion, this could even cause some stack overflow if you have a long list. A variation on jvkr’s zl solution.


-- Pasted Max Patch, click to expand. --

Feb 10 2011 | 5:05 pm

With an example of stack overflow…


-- Pasted Max Patch, click to expand. --

Viewing 9 posts - 1 through 9 (of 9 total)

Forums > MaxMSP