On 5/16/2004 12:50 PM, Mike Blezien wrote:
Hello,
is it possible, with perl, to find the closest numerical value to a set value. IE. a set value of 15 and I have five values, 208,258,56,123
is there a function too go through the five values array to find the closest to 15 ??
If it's an unsorted list and you only need to search once, your best bet is to walk the list. OTOH if your going to be searching multiple times, you will be better off to sort the list and then use a binary search algorithm.
Randy.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>