- 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;
- or download this
sub binsearch(&$\@) {
my $compare = $_[0];
...
}
sub _unsigned_to_signed { unpack('j', pack('J', $_[0])) }
- 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;
- or download this
sub binsearch(&\@) {
my ($compare, $array) = @_;
...
}
sub _unsigned_to_signed { unpack('j', pack('J', $_[0])) }