[HOW TO?] analysing lists

Tiago Morgado's icon

hi guys

Hope everything is just fine with all of you.
I need an hint on how to solve a problem.

I have an input of a list with four elements..

eg: 1 2 3 4

the values are intigers between 0 and 1

I then have a permutation of all those elements (4^2 = 16):

0000
1000
0100
0010
0001
0011
1100
1001
1010
0101
0110
1110
0111
1011
1101
1111

and then I want to analyse this list and detect which one is being triggered..

can you give me an hint on how to do this.. so that I can spend some time on it trying to solve this problem myself?

thanks in advance
tiago morgado

seejayjames's icon

you can convert this binary representation to an int, then use [sel] to pick which one it is (0-15 are possible). lots of ways to do it.

Tiago Morgado's icon

ok.. thanks man.. I will try it..

Tiago Morgado's icon
Max Patch
Copy patch and select New From Clipboard in Max.

you mean something like this right?

thanks
tiago morgado

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

or this:

Tiago Morgado's icon

thanks terry.. it's a much more effective way of solving the problem.. and with a much more advanced programming max level.. in fact it almost seems that you're making some c++ script by using maxmsp objects

Floating Point's icon

If you're interested, have a look at the help patches for these objects: the sprintf object uses C nomenclature, and the jstrigger object uses javascript

Luke Hall's icon

If you need to scale this to different numbers of bits then you can use this alone without needing the [sprintf] object.alone without needing the [sprintf] object:

jstrigger (parseInt(parseInt(a.join().replace(',','','g'),2).toString(10)))

Tiago Morgado's icon

in fact sprintf is a c/c++ function..
for simple operation jstrigger seems to be effective and you don't need to create an external with js objects for putting simple instructions to maxmsp..

thanks guys