Lace/interleave more than two lists

Jun 19, 2011 at 8:38pm

Lace/interleave more than two lists

Hi Forums,

I’m working a lot with lists, but can seem to get my head around a way to lace/interleave three lists. The [zl] object has a wonderful ‘lace’ function, that interleaves two lists. How can this functionality be extended to three or more lists?

An example:

message-box1: 100 200 300 400
message-box2: 3000 5000 1000 7000
message-box3: 0.1 -0.2 0.3 -0.4

I would like these to be interleaved as:

list: 100 3000 0.1 200 5000 -0.2 300 1000 0.3 400 7000 -0.4

Is it possible to process lists like this? I’m stuck in getting a the first element out of all lists, then the second, then the third, an so on.

I’ve tried combining [zl len] (the number of elements in the lists), with some [uzi]/[counter] stuff (to get a series of numbers to list) and then a [zl nth] to get the first, second, third element out (and finally an [append $1] message to add them to the list). But this seems rather clumsy, and I can’t get it to work.

Any help or hint would be very appreciated! :)

#57679
Jun 19, 2011 at 8:56pm

Here’s a javascript “lh.lace” which you can save in a [js] object which will work like [zl lace] for more than 2 lists. You can set the number of inlets with a number argument. I’ll include the help file patch below as well.

// lh.lace.js

var num = jsarguments[1];
inlets = Math.max(2,num);

var store = new Array(num);
for (i=0; i 0) {
            for (j=0; j

----------begin_max5_patcher----------
924.3oc0W0zaaiCD8r8uhA5rWAQ8s6sE608XusonfhhVloRhBjToIsn+22Qj
RIxM1ptNNos.IjVjCG9dugyHputdkWg7dt1CdG7evpUec8pU1gFFX03yq7Zn
2ypoZqYdMbslVw813lyvu2XGmUyopoQ2IaMszFtcl+VIn0SyzQMr8h1pOp3L
iaeyR7C1.jn3gtnL6C49AvGFWhnz5FYws+U7jaZ6aDs0biESgy1Us3K1ckDh
94Qak8lIiIii5Fx7PG2gBOO3CCy7s0qGZ1blxQQuwHaWfcDRridQCcgASsGi
dgGkdjeNdTPaqtLtbpPaDbimVbOj5GEDisa2diGX+6hh2gYoNEwE2C2tTDOJ
32tP9ojIBDeQ5AY7LuSOhB8SVPNB+iQNBgDHC1dYRR9bIIdwZBQQ+wHIQPJj
eY4LQyyYVtHYzueUIa4eFQ1yziNkn0.Jttu17hRcxskUSyVp3ZTxhUWOKYI3
5w8a0P8d+ZJiCQuHtmja6H4KR9ziR9negmIXxlFdq4YBy62Kzvsz6nZlRzY.
C8SbMHa4.UU0OrDvHAMG61yADhEbEH2ANV4C+qPaz37N6Paz7w4PGvAbaKDs
7RPX3MPwCt9cJYCTy2YWiRTs29ClhSMb6dijtq2.0ny8g2ia7NgRabNFL3Jp
3JsEQcJICy+cVci80w36JGKILfqR8f2FskemP1qqe.XzZVeMtckOtInN37Os
VKAJiw6Lt83F20sl4WDskbzVtcdVuRgB.51875RjysF7Qs+jXWiJ.S12ZU73
K4zm8k1I11XWw5zSbzK9mHui3mrMAK9e0R99tCY2QUOxPZuQhpS2GMR7eAtM
O6n3XBp2EKPYN8wUzdt9rSUU3rKveazlmZyvT4iqiDxb7wj0R043gSJ56FX1
IpAfkQxyvqrl+lGHJEUb8yKJ7OtrVsM2PePt6kGcFucgK7DRdggmvqa3YV43
rj3rfjqVnni1xq+gAhCrpRQKCmnSdxlCZmSmiH01O+w0r0pzIgyVPirjOm5y
Uz3EKbTPYepRgEwJO8GIELC+jI7ShIjrzAzGlDrMe3GDrOHdjJyjTKLsUK+t
uQ1xygwOTm0xdEa50hS2WGdhsk3YaQK0HvOYblQoGXzdQYIucN7aDkcR7pRi
f3Dut8rwTz4hIxaGlhOWLE91gofWALEhUaFxYRbEche5oWJZSOGzl7ldR603
vOILZl.RhSuVBX7q.XyiOGrhO7s0+OPhHEpm
-----------end_max5_patcher-----------
#206693
Jun 19, 2011 at 8:57pm

it would probably be worth meditating on the following three objects:

1. iter
2. pack
3. trigger

#206694
Jun 19, 2011 at 9:49pm

Thanx to both of you! :)

@Luke Hall: I’ll check out your JavaScript object. This is quite interesting to me, as I’ve done some JavaScript coding elsewhere, but haven’t combined it with Max. Maybe it could ease up more tasks like this :)

@Gregory Taylor: Cool. I definitely like [iter].

In the meantime I actually made my approach work, though still clumsy and ugly:

– Pasted Max Patch, click to expand. –

More suggestions or discussion are very welcome :)

#206695
Jun 19, 2011 at 10:03pm

there’s a CNMAT object which can interleave 3 (or more? can’t recall). Lots and lots of other great objects in there too…

#206696
Jul 17, 2011 at 3:53pm

There’s also mxj list.Multiplex.

#206697
Jan 18, 2012 at 7:13pm

This isn’t an all-purpose solution, but if you know how many lists you want to interleave and the type of items they will contain, you can do something like this (Max objects only).

– Pasted Max Patch, click to expand. –
#206698
Jan 18, 2012 at 8:38pm

I think Peter Elsea’s Llace does it.

#206699
Sep 15, 2013 at 3:55am

I think Peter Elsea’s Llace does it.

You may be thinking of Lmerge… which allows iterations of up to 9 elements to be interlaced from multiple lists.

#265306

You must be logged in to reply to this topic.