[HOW TO?] analysing lists
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
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.
ok.. thanks man.. I will try it..
you mean something like this right?
thanks
tiago morgado
or this:
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
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
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)))
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