Forums > Max For Live

List trick

November 13, 2013 | 4:07 am

Hello everybody,

I search a simple a accurate way to create a list as :
- I have an input list of n items
- I want to create a new list of m items using only some items of my original list.

I can use zl.slice to extract the items from the original list, but is there a function which create a list from x items and repeat them to have a m items list.

Hope it’s clear.
Thank you for your answers.


November 13, 2013 | 5:28 am

That’s very general.. Perhaps this is useful?

-

– Pasted Max Patch, click to expand. –

November 13, 2013 | 8:54 am

Thank you very much, you just confirm that i am on the good way.


November 13, 2013 | 9:35 am

Here is the result, may be you have some improvements to make :

<code>

– Pasted Max Patch, click to expand. –

</code>


November 13, 2013 | 1:23 pm

I don’t understand what you are trying to do here…

Example input.. example output? What kind of steps?


November 13, 2013 | 11:06 pm

Ok, here is the patcher spec :
- In the second inlet, you send a list (of steps). ex. : 1 2 3 4 5 6 7 8
- In the first inlet, you send the number of steps (or items) of the lists you want to copy (duplicate). ex. : 2

The patcher must create a list as same length as the original list (inlet 2) but containing copied items (steps, inlet 1) of the original list.

So for : (Inlet 1 : 2, Inlet 2 : 1 2 3 4 5 6 7 8
Then the result must be : 1 2 1 2 1 2 1 2

For : (Inlet 1 : 4, Inlet 2 : 1 2 3 4 5 6 7 8
Then the result must be : 1 2 3 4 1 2 3 4

And if the Inlet 1 value is greater or equal to Inlet 2 list length, nothing is made, because it’s not usefull.

Is it more clear ?


November 14, 2013 | 5:28 am

Ahh.. I see. Well it looks like you worked it out. Optimization will likely be a function of how you are using it.. Maybe add a modulo object to allow for inlet 1: 3, result: 1 2 3 1 2 3 1 2 etc..


November 14, 2013 | 5:34 am

This thread is somewhat related. It might give you some more ideas.. http://cycling74.com/forums/topic/iterate-over-list-n-times/


November 15, 2013 | 3:43 am

Thank you for your help, I will take a look at your link.

Regards.


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