On Fri, Apr 24, 2009 at 9:38 AM, Rob Redmon <rob.webinator / gmail.com> wrote:
> [...]
> Find the two elements in a1 who are nearest neighbors to the scalar
> s.  ¨Β ξεεδ τθιξδιγενοςε τθαξ τθφαμυεσ>
> Clearly, I can find the nearest values with this:
>>> [10,20,30,40,50].find_all{|item| item >= 25 }.first
> => 30
>>> [10,20,30,40,50].find_all{|item| item <= 25 }.last
> => 20
>
> How do I get the matched indices?  ¨Βθαισχιτθουυημω μοοπσ®

#index and #rindex in their block forms come to mind:
http://ruby-doc.org/core-1.9/classes/Array.html#M001974

cheers,
lasitha