Forums > MaxMSP

mixing lists …


Per
March 9, 2012 | 1:34 pm

hi

I have 4 lists. say:

[1 5 9 13]
[2 6 10 14]
[3 7 11 15]
[4 8 12 16]

I want to combine them to:
[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]

how do I manage this. been looking at the zl object but cant find any solution

thanks



pm
March 9, 2012 | 1:58 pm

[join] is the way to go!

– Pasted Max Patch, click to expand. –

March 9, 2012 | 2:06 pm

pm: those aren’t random lists, joins lists consecutively, doesn’t work with random numbers.
only one thing you missed, not much. :)
corrected: (entered lists as OP, added zl.join)

– Pasted Max Patch, click to expand. –


pm
March 9, 2012 | 2:32 pm

Sorry, but isn’t it the same thing I did?


March 9, 2012 | 2:38 pm

Not as I understand. Your source messages were already sorted (from 1-16, split in 4), OP wanted split random messages to end up joined *and* sorted.
Basically, you forgot the zl.sort object and nothing else.



Per
March 9, 2012 | 2:47 pm

okej thanks. but maybe a bad example from me. what I want to do is to output every single pixel in a matrix as a list.

Ive done like this know and got a list of all the matrix through the join object but now I want to rearrange and pack again. So I get the individual pixel as a ARGB list. But how do I sort them?

Best would be if there would be an object that took every fourth number in a list and outputed it in a list of four through in in this case four outputs

………
So:
I would like to output every fourth number in four different lists
………

like in the patch below:

– Pasted Max Patch, click to expand. –

March 9, 2012 | 8:15 pm

If i understand correctly, here are 3 ways of doing it.
way 1 and 2 are very similar. way 3 has the least objects but its as clumsy as it gets.
output is exactly the same. i used defer low for the button for triggering lookups so it triggers the lookup only after the new value is stored in zl.lookup. You could do with with proper message ordering (putting button most left and bottom if i recall) but I’m a lazy man and I never remember how to properly order messages.

basically, zl.lookup does the "nth element of the list".
You can use zl.iter after zl.lookup to output 4 successive lists instead of 4 parallel lists for inputting to i.e. database object. (coll, pattr)

– Pasted Max Patch, click to expand. –

`


March 9, 2012 | 8:52 pm

i believe that
[zl iter 1] [zl iter 1] [zl iter 1] [zl iter 1]
[zl group 4]
[zl group 16]
is all you need.



Per
March 9, 2012 | 10:04 pm

okej thanks. probably its me who not understands the help patch for some of the zl objects. cause what does they mean by the nth and mth element?

………………..
WHAT is nth and mth??
………………..

heres my solution. maybe not the best but at least working:

………..
another thing ive been thinking of. is there a better way of splitting up something that is printed on four different rows in maxwindow to also come to four different messageboxes ->>

for example if something is printed in maxwindow like this:
255 133 119 100
255 91 83 86
255 118 114 92
255 81 67 81

how do I output them the same in messageboxes in a good way
………..
and my patch solution:

– Pasted Max Patch, click to expand. –

March 9, 2012 | 10:05 pm

I can’t see how though, he wants it resorted, iter will just output everything in a list, and group will put it into a list back together? I don’t get it.



Per
March 9, 2012 | 11:06 pm

I couldnt get it either Roman Thilenius …

what about nth and mth?
its some kind of mathematical expression I guess but what does it mean?

thanks for help!!!


March 10, 2012 | 12:44 am

didn’t try all patches, but i think all you need is three of [zl lace].

– Pasted Max Patch, click to expand. –

March 10, 2012 | 9:47 am

xldance: that essentially just sorts them, he needs to split them and output interleaved in a specific order.

per katapult: I’d think my solution are a tad simpler than that, if not anything else, no counter and it outputs them at the same time.



Per
March 10, 2012 | 4:19 pm

yes thanks. i think im going to use the packunpack method. that must be the least heavy way to handle this.

this is just a small piece of a thing im working on. Ive got a HUGE list and a very big patch and used the slice method first a couple of months ago but now I need to rewrite the patch cause the slice method was to heavy combined with a lot of other things. so need to slim things down.

thanks for all inputs!!!

Ill make a new thread with the nth and mth question


March 10, 2012 | 6:07 pm

This is a bit late, responding to your original posting. But here’s where knowledge of other ‘tools’ may be very helpful. Using lisp, the code to do your original task is this:

(setf a ‘(1 5 9 13))
(setf b ‘(2 6 10 14))
(setf c ‘(3 7 11 15))
(setf d ‘(4 8 12 16))
(sort (append a b c d) #’< )

maxlispj: http://music.columbia.edu/~brad/maxlispj

brad

http://music.columbia.edu/~brad


March 10, 2012 | 7:01 pm

yeah right i am wrong, my solution would require a buddy or zl nth or something like that after the iter … and then it is too many objects already … at least not less than using unpack and pack (which would have been my aim)


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