## List trick

Nov 13, 2013 at 4:07am

# List trick

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.

#271067
Nov 13, 2013 at 5:28am

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

-

– Pasted Max Patch, click to expand. –
#271073
Nov 13, 2013 at 8:54am

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

#271111
Nov 13, 2013 at 9:35am

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

<code>

– Pasted Max Patch, click to expand. –

</code>

#271116
Nov 13, 2013 at 1:23pm

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

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

#271137
Nov 13, 2013 at 11:06pm

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 ?

#271189
Nov 14, 2013 at 5:28am

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

#271209
Nov 14, 2013 at 5:34am

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

#271212
Nov 15, 2013 at 3:43am