Simple (?) recursion problem. Can M4L even do recursion?!

Dec 29, 2013 at 3:47pm

Simple (?) recursion problem. Can M4L even do recursion?!

Hi all,
In this simplified version of my patch, I am trying to use an [uzi] recursively, but it won’t work. :( I don’t necessarily need the [uzi], but I need to be able to do recursion.

Here’s a cheesy view of the problem:

.         ______________
         |              |         Clicking the message ["5"] gets...
["5"]   ["2"]           |
   |     /              |         1,2,3,1,2,4,3
   |   /                |
   | /                  |         If [uzi] supported recursion,
[_uzi  _     _ ]        |         then output would be...
            /|          |
          /  |          |         1,2,3,1,2,4,5
        /    |          |
      /      |          |         ...which is what I want.
    /        |          |
  [print]  [select 4]   |
             |__________|

How can I simulate recursion in this example?
Are there M4L objects that *do* support recursion?
Please help!

Thx in advance,
Miguel3d

#276907
Dec 30, 2013 at 1:58am

It seems that Max objects are generally not designed to handle “recursive calls”, but the behavior can be simulated by using multiple instances of the object. Do you think that’s a serious limitation in practice?

<code>

– Pasted Max Patch, click to expand. –

</code>

#276931
Dec 30, 2013 at 2:40am

Hi Broc, thx for replying.

The example above is just a simplification. My actual goal here is to generate a list of all devices on the track, including those in all chains, by traversing the track’s device hierarchy recursively. I don’t know the depth of the hierarchy beforehand.

Right now I’m trying to simulate using [zl stack], but having trouble. :(

#276932
Dec 30, 2013 at 3:27am

Yes, recursion can generally be simulated/implemented with a stack.
But you may also consider using Javascript for traversing the device hierarchy.

#276938

You must be logged in to reply to this topic.