Comparing to a list

Jul 24, 2009 at 2:54pm

Comparing to a list

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

#44872
Jul 24, 2009 at 4:27pm

Hi,

There’s many way.

Something like that could do the trick :

– Pasted Max Patch, click to expand. –
#161546
Jul 24, 2009 at 5:05pm

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], [==] …

#161547

You must be logged in to reply to this topic.