Lace/interleave more than two lists

    Jun 19 2011 | 8:38 pm
    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! :)

    • Jun 19 2011 | 8:56 pm
      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
    • Jun 19 2011 | 8:57 pm
      it would probably be worth meditating on the following three objects:
      1. iter 2. pack 3. trigger
    • Jun 19 2011 | 9:49 pm
      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:
      More suggestions or discussion are very welcome :)
    • Jun 19 2011 | 10:03 pm
      there's a CNMAT object which can interleave 3 (or more? can't recall). Lots and lots of other great objects in there too...
    • Jul 17 2011 | 3:53 pm
      There's also mxj list.Multiplex.
    • Jan 18 2012 | 7:13 pm
      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).
    • Jan 18 2012 | 8:38 pm
      I think Peter Elsea's Llace does it.
    • Sep 15 2013 | 10:55 am
      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.