Reverse searching a 'coll' object for indices

James McAleese's icon

Can I search for the index of a message stored in a coll object? For example if I have a list of songs stored in coll and I want to be able to pull the index of the song so it can be used elsewhere in the patch, is there an object or a series of objects that would let me do so?

Source Audio's icon

that is easy to do, but depends on the structure of stored data in the coll.
if you dump coll contents, it outputs both data and index
one can use that to trigger index when searched data part gets detected.
paste some data here so that form in coll is visible
Having a list of Songs in umenu would be more practical, because
umenu items can get recalled by both item number and item symbol

here one example

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

If index is not numeric, use zl reg for example

James McAleese's icon

This worked great, thanks so much!

Source Audio's icon

you are welcome.
Just a notice - iter is inserted in case
data has more items in the list than just song name
Also coll prepends "symbol" to output when data
is a single symbol.

like here :

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

route symbol gets rid of it

Mario Fernando Cardoso's icon

Hi! This is amazing...
Any clue of how to do this but with lists or with more than one value? So I can extract the indexes containing two given values ore more? For example: look for the indexes containing both 0 and 4.

0, 0 1 2 4;
1, 0 2 3 5;
2, 5 4 3 0;
3, 2 3 0 4;
4, 8 2 4 9;
5, 2 3 5 6;

In this example, the correct answer would be indexes: 0 2 3
Notice that is not enough that just one of those numers (0 or 4) is present alone, both of them are neccesary.
Notice that it doesn't matter the order in which the numbers appear nor if they are separated by other numbers or not.

Any clue?

Thanks!!

Source Audio's icon

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

Mario Fernando Cardoso's icon

Thanks!
I will take a look to this

Mario Fernando Cardoso's icon

Hi!
Thanks for sharing this solution... it's a great progress!
However, I have an issue.
It seems that the selection is not strict. Usually works fine, but sometimes makes wrong selections. When sending a list of multiple items to compare, it's only supposed to show options that contain all the items we are sending, but sometimes it shows options that share only 1 item.
I found a solution that seems to work so far for what I'm looking to do. But I wanted to share this anyway so maybe you guys can help me fully understand what went wrong, or maybe you can share a different way to fix it.

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


Thanks again!

Source Audio's icon

problem were duplIcate matched items

here is a bit simpler patch

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

Mario Fernando Cardoso's icon

Oh got it.
Thank you!

Roman Thilenius's icon

dump into another coll, reverse the data structure, search new coll?