add elements in a list, using 0 as a break

kezia salmon's icon

hello!

i am working on a project that generates a series of binary numbers i.e. 1 0 1 1 0

i have collected these into lists

but i wish to export these in the format, using the example above, 1 2

another example just to make it clear would be that the system spits out 1 1 1 0 1, and i would want that to display as 3 1

basically, add adjacent numbers in the list but ignore 0

i'm sure there's a very obvious answer that i'm missing but if anyone can help, it would be massively aprpeciated!

thank you

Source Audio's icon

iter the list, add all == 1 till next zero

then continue till the end of list

zl objects can help you.

kezia salmon's icon

so that's the theory that i'm working on

but the question is how to do that in practicality

double_UG's icon
Max Patch
Copy patch and select New From Clipboard in Max.

............................................................

kezia salmon's icon

thanks double!

that's exactly the ticket!

TFL's icon

My take on it, using [accum]

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