Forums > MaxMSP

Comparing to a list

July 24, 2009 | 2:54 pm

I am trying to find the best way to take a list (varying length) of values which increment upward, and compare them to another value. The result of this should return the two values which it was between (more preferably I’d like it to return the index at which it was found)

ie comparing 5024 to this list:

(assuming the first element is defined as element 1)

0 2423 4865 6057

should output 3 and 4

Cheers, Ben

July 24, 2009 | 4:27 pm


There’s many way.

Something like that could do the trick :

– Pasted Max Patch, click to expand. –

July 24, 2009 | 5:05 pm

one way would be to append it to the list, sort the list again,
and then finding its position by comparing with itself using
[zl iter 1], [counter], [==] …

Viewing 3 posts - 1 through 3 (of 3 total)