Find a number

Rui Travasso's icon

Hello,

I am sending number from a coll to a jit.cellblock and now I would like to find if there are repeated numbers and, if it finds a number, to add a counter in the next colunn.

Is that possible to do directly in a coll?

Thanks

Andy Maskell's icon

I think that you are not going to get much help on this with so little information. Are you able to post any patch that you have created so far and/or more detail about the scope of these numbers - integer/float, range of values. Is your [coll] currently just a list of single values or is there other data in there as well.

Roman Thilenius's icon

coll allows only operations to adresses (not to the data content): sort, insert, move, next, renumber, call and return, associate, dump all, delete... and file in/out.

"check if it contains free beer, and if yes, multiply the 3rd element with 77" has to be done outside.

building a generalized routine of the sort "get the data from index 3, do something with it, write the result back into index 3" is not complicated.

the help file might not show all commands, you want to look into the object´s reference.

Source Audio's icon

I guess he wants to add repetitions into same row.

If it is so, then :

Rui Travasso's icon

Hello,

Thank you for your help.

I am sorry for had given so little information.

What I am trying to do is to receive numbers with 9 digits; add a extra digit - for counting; and, if the number is repeated, to add 1 to the counter - the extra digit.

I am using the coll to kepp data and the zl.look to extract the numbers from the coll and to compare.

My patch is now too much confunsing. Actually I have two in the same one. The first is keeping the data and comparing (above). The second one (below) I was developing it to add 1 to the digit number 10.

Maybe it´s to confunsing. I will try to clean it and I will post it again.

Thank you very much for your help

counter.maxpat
Max Patch

Source Audio's icon

you should never name a patch same as existing max object/external.

post comments in the patch in english ...

and yes, it is not clear what you want to do.

I understand feeding a coll with 9 digit numbers,

adding indexes using idx (same could be done with counter).

Allready there you could merge as shown in my example

to stack repetitions and do something with them,

for example add number of repetitions as that "extra" digit

....

what is completely confusing is how many digits you want to add to

original 9 ones ?

if you receive more than 9 numbers, you can't just add 1 digit- digit number 10.

I hope you understand waht one digit is ?

one single item 0-9

Rui Travasso's icon

Ok,

it´s changed

repetitions.maxpat
Max Patch


Source Audio's icon

have a look at this, is that kind of what you want ?

Rui Travasso's icon

Thanks,

in what you´ve send each repetition goes to a new colunn, is that right?

It could work. I was thinking adding the number of repetitions to the number. Something like this:

999999999 2 - meaning this number was sent twice

888888888 5 - meaning this number was sent five times

I know what a digit is. I was thinking in something like the image.

But maybe what you´ve sent could work for my intention. The problem it will be if a number has high number of repetitions.

Thank you very much

Source Audio's icon

one can avoid adding repetitions to columns,

but add only number of repetitions if you want that,

or add IDs as they get in into new columns and count number of repetitiins

on coll dump.

But I don't see any use for numbering ID's of incomming numbers ?

if you have 999999999 9

that means it got ID 9 ,

a repetition could have ID 88.

what then ?

makes no sense.

Either remove ID's and only count number of repetitions,

or maybe keep very first ID of a number and add number of repetitions as

THIRD value :

999999999 16 3 (16 was first ID) (number got repeated 3 times)

Source Audio's icon
Max Patch
Copy patch and select New From Clipboard in Max.

P.S. If you don't want to use ID's at all use this

Rui Travasso's icon

I´m not sure I understood de IDs.

Is the IDs refering to a col $ and row $?

So, can you show me the solution if to count repetitions in a colunn?

I was looking to do something simple.

Receive a number > if the number doesn´t exist it should put in a new IDX (in a coll) or a row (in cell) > if the number already exist it ativates a counter addind an adjacent number counting the repetitions (example: 21 2; the number 22 had shown twice).

I´m sure there is a easy way to do this but I can´t figure out.

Rui Travasso's icon

I see now what you posted. I think is this.
Thanks

Rui Travasso's icon

Yes, is really what I was looking for!

Thank you very much!

Rui Travasso's icon

I get almost all code but I don´t understand how the Coll result gets the info.

Do you mind to explain me?

So, the coll result is counting the colunn from coll merger, right? but from where?

Thanks once again

Source Audio's icon

in coll we use terms index for address, and data which can be single item

or list of several types of items.

that could translate into column 0 in jit.cellblock for index

followed by other values into subsequent columns in one row.

coll result receives 2 or 3 items, depending on which version you decided to use :

with or without ID's of received numbers.

last item is number of occurances

which gets reported from zl.len (reports list length).

Rui Travasso's icon

Perfect, thank you!