Empty lists are not output from zl objects

Alexander Wallin's icon

Hello!

Trying to solve a few different problems the last couple of days, I've been running into issues with zl objects, namely that whenever the result is an empty list, the object doesn't output anything.

For instance when filtering [123] from the list [123], nothing happens. Or when utilizing the right output of zl.nth, providing the original list with the fetched item excluded, it goes mute when there are no more items left. In both cases it's impossible to know when the last object in a list was removed.

I'm pretty novice with Max still, so I'm hoping there's another approach or way of thinking that is better suited. Maybe I'm stuck in classic programmatic thinking, but it all seems rather odd to me.

Use case: you create a random seed that you pick elements from, and when it's empty you refill it. Might be any number of elements.

Any pointers?

Jean-Francois Charles's icon

I would use two most important objects in Max: [gate] and [t]

Max Patch
Copy patch and select New From Clipboard in Max.

JBG's icon

Yeah, this is a bit of a nuisance. It would've been so nice if [zl] had an option to output a null/emptylist element when applicable, but unfortunately that's not the case.

A slightly more generalized solution that works with any zl object and any outlet is to use an intermediate [zl.reg] that you set to your own "null" value (note that "null" doesn't have any significance in Max, it's just a string like any other):

Max Patch
Copy patch and select New From Clipboard in Max.

Then you can just use [route null] to handle the null case separately, when needed

Source Audio's icon

you can make something simple that reports

"no output" or something like that if no result from zl, coll and similar objects.

Alexander Wallin's icon

Thanks for the suggestions! That gate trick was neat, I'll try to use that.