mixing lists …

Mar 9, 2012 at 1:34pm

mixing lists …

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

#62261
Mar 9, 2012 at 1:58pm

[join] is the way to go!

– Pasted Max Patch, click to expand. –
#224940
Mar 9, 2012 at 2:06pm

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. –
#224941
Mar 9, 2012 at 2:32pm

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

#224942
Mar 9, 2012 at 2:38pm

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.

#224943
Mar 9, 2012 at 2:47pm

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. –
#224944
Mar 9, 2012 at 8:15pm

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. –

`

#224945
Mar 9, 2012 at 8:52pm

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.

#224946
Mar 9, 2012 at 10:04pm

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. –
#224947
Mar 9, 2012 at 10:05pm

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.

#224948
Mar 9, 2012 at 11:06pm

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!!!

#224949
Mar 10, 2012 at 12:44am

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

– Pasted Max Patch, click to expand. –
#224950
Mar 10, 2012 at 9:47am

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.

#224951
Mar 10, 2012 at 4:19pm

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

#224952
Mar 10, 2012 at 6:07pm

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

#224953
Mar 10, 2012 at 7:01pm

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)

#224954

You must be logged in to reply to this topic.