splitting up a list
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.
I guess this sort of answers my own question, kind of a brute-force approach, tho. Is there a better way?
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
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?
Chris Muir
cbm@well.com
http://www.xfade.com
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:
and this:
lists of binary data into and out of lists of integer data
and the difference between the input and output format of matrixctrl object
Here's my take on how to do it without so much hassle, there could very well be ways using even less objects.
lh
wow, thanks! I will try these