Help for this page

Select Code to Download


  1. or download this
    my $idx = binsearch { $a <=> $b } $val, @array;
    if ($idx < 0) {
       $idx = ~$idx;
       --$idx if $idx > 0 && $val - $array[$idx-1] <= $array[$idx] - $val;
    }