- or download this
sub fisher_yates_shuffle {
my $array = shift;
my $i;
...
@$array[$i,$j] = @$array[$j,$i];
}
}
- or download this
for (0..($#arr-1)) {
$n = int (rand() * ($#arr - $_ + 1)) + $_;
$t = $arr[$n];
$arr[$n] = $arr[$_];
$arr[$_] = $t;
}
- or download this
for (0..($#arr-1)) {
$n = int (rand() * ($#arr - $_ + 1)) + $_;
- or download this
$t = $arr[$n];
$arr[$n] = $arr[$_];
$arr[$_] = $t;
- or download this
}
- or download this
for (0..($#arr-1)) {
$n = int (rand() * ($#arr - $_ + 1)) + $_;
- or download this
@$arr[$_,$n] = @$arr[$n,$_];
- or download this
}
- or download this
for (0..($#arr-1)) {
$n = int (rand() * ($#arr - $_ + 1)) + $_;
- or download this
# next if $_ == $n;
- or download this
@$arr[$_,$n] = @$arr[$n,$_];
}
- or download this
for (0..($#arr-1)) { # Your Version
$n = int (rand() * ($#arr - $_ + 1)) + $_;
for ($i = @$array; --$i; ) { # Fisher-Yates
my $j = int rand ($i+1);
- or download this
for (0..($#arr-1)) {
$n = int (
- or download this
rand() * ($#arr - $_ + 1)
- or download this
) + $_;
# next if $_ == $n;
@$arr[$_,$n] = @$arr[$n,$_];
}
- or download this
for (0..($#arr-1)) {
$n = int (
- or download this
rand($#arr - $_ + 1)
- or download this
) + $_;
# next if $_ == $n;
@$arr[$_,$n] = @$arr[$n,$_];
}
- or download this
for (0..($#arr-1)) {
$n = int (rand($#arr - $_ + 1))
- or download this
+ $_
- or download this
;
# next if $_ == $n;
@$arr[$_,$n] = @$arr[$n,$_];
}