splitting up a list

phineus's icon

I have a list of 64 values (0s and 1s e.g. 8 binary numbers) and I need to quickly split this into 8 separate chunks to be converted to 8 integers. I have code to convert 8 1s and 0s to an integer, but I can't figure a fast way to split up the list. I tried zl slice but that required slicing the list 8 times and was slow. Maybe some object exists for this e.g. -> take my list of 64 values and return 8 lists of 8 values? Any help appreciated, I've already spent too much time on this little problem.

phineus's icon

I guess this sort of answers my own question, kind of a brute-force approach, tho. Is there a better way?

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

Chris Muir's icon

On Dec 26, 2008, at 9:25 AM, phineus wrote:

> Maybe some object exists for this e.g. -> take my list of 64 values
> and return 8 lists of 8 values?

You shouldn't have stopped looking at zl. [zl iter 8] should do what
you want. It will chop your list into chunks of 8.

- C

Chris Muir
cbm@well.com    
http://www.xfade.com

Chris Muir's icon

On Dec 26, 2008, at 9:38 AM, phineus wrote:

> I guess this sort of answers my own question, kind of a brute-force
> approach, tho. Is there a better way?

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

Chris Muir
cbm@well.com    
http://www.xfade.com

phineus's icon

Thanks Chris - that is indeed much faster and more elegant! I think I understand how it works. Now I'm trying to apply similar logic to this:

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

and this:

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

lists of binary data into and out of lists of integer data

and the difference between the input and output format of matrixctrl object

Luke Hall's icon

Here's my take on how to do it without so much hassle, there could very well be ways using even less objects.

lh

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

phineus's icon

wow, thanks! I will try these