Counting occurrences of numbers in a list in RNBO

thomas zalud's icon

I’m looking for an object or patch that can take a list of numbers and tell me how many times each number occurs. Any suggestions?

TFL's icon

This is my very first patch with RNBO, so not sure if it's the best way to do it but it seems to work assuming you know the numbers you want to count.

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

Then I realized you have list.* objects, so I did this:

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

No need to know which numbers are in the list in advance, and will output a list with pairs of numbers. Like 1 1 0 0 1 1 2 will output 0 2 1 4 2 1 meaning 0 is present two times, 1 four times and 2 one time

thomas zalud's icon

Thanks, that really helps!

thomas zalud's icon

After counting how often each number appears, how can I extract the number that occurs most frequently? What would be the best way in Max/RNBO to filter out the highest-occurring value from the result?

Roman Thilenius's icon

as long as in doubt if there is a quicker solution for some required list processing, start with iterating it into single elements.

if the numbers and/or how many of them will appear is not known, the process will look similar to what is known as "running status" around here, and probably be built around a [coll], which stores the value/amount pairs for you.