Answer the question
In order to leave comments, you need to log in
How to interpret PERL code in PHP?
Hi all! Have I translated perl to php correctly?
PERL
my @indexes;
for my $i ( 0 .. $L - 1 ) {
my %seen;
while (1) {
my $rand = int( rand( $self->d * $SCALE ) );
if ( !$seen{$rand} ) {
$seen{$rand} = 1;
last if keys %seen == $self->k * $SCALE; // ??????
}
}
push( @indexes, [ sort { $a <=> $b } keys %seen ] );
}
$self->_indexes( \@indexes );
$indexes = null;
for($q=0; $q<$L; $q++){
$seen = null;
while(true){
$rand = rand(0, $d*$SCALE);
if(!$seen[$rand]){
$seen[$rand] = 1;
if(count($seen) == $k * $SCALE)
break;
}
}
$indexes[] = asort($seen);
}
Answer the question
In order to leave comments, you need to log in
Yes, you translated correctly.
Exactly the opposite.
You need to simply open any reference book on perl and read about hashes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question