Help for this page

Select Code to Download


  1. or download this
    # Add $value to sorted @array, if it's not already there.
    my $idx = binsearch { $a <=> $b } $value, @array;
    splice(@array, ~$idx, 0, $value) if $idx < 0;
    
  2. or download this
    sub binsearch(&$\@) {
       my  $compare = $_[0];
    ...
    }
    
    sub _unsigned_to_signed { unpack('j', pack('J', $_[0])) }
    
  3. or download this
    # Add $value to sorted @array, if it's not already there.
    my $idx = binsearch { $value <=> $::_ } @array;
    splice(@array, ~$idx, 0, $value) if $idx < 0;
    
  4. or download this
    sub binsearch(&\@) {
       my ($compare, $array) = @_;
    ...
    }
    
    sub _unsigned_to_signed { unpack('j', pack('J', $_[0])) }