Hi!

I'm searching for a light method for finding the closest items to a given
value.

example/

1..10
in a range
i give,  5.5, return  5 and 6  for example....

as i'm working with arrays, containing numbers, but with no regular step...
it will change i think.
example..

a = [ 1, 1.25, 2, 3, 3.5 ]

if i give 1.85, it gives me 1.25 and 2

It's for a little music game, where player has to tap at the right moment,
notes are register in a array, with the correct time, and as players can't
be accurate as a computer, i need some error margin. I working with  0.05
rounded values.


Also, if someone knows a good way to synchro Scrolling and Music with tempo
value that would be great... 
I mean, not the conversion to find how many frames between each beats. but
how to convert, the number of frames between 2 beat to a distance in
pixel...? ( and possibly with a set-able speed) ?


Thanks.

-- 
View this message in context: http://www.nabble.com/find-the-closest-items-in-an-array-to-a-given-value.-tf4714369.html#a13475984
Sent from the ruby-talk mailing list archive at Nabble.com.