[kw-pm] Doctor Perl
lloyd carr
dcarr at sdf.lonestar.org
Mon Feb 28 18:32:44 PST 2005
Dear Doctor Perl,
I could use this-
use List::Util shuffle;
my @tiles = 0..10816;
shuffle( @tiles );
or this-
my @array = 0..10816;
# fisher_yates_shuffle( \@array ) :
# generate a random permutation of @array in place
sub fisher_yates_shuffle {
my $array = shift;
my $i;
for ($i = @$array; --$i; ) {
my $j = int rand ($i+1);
next if $i == $j;
@$array[$i,$j] = @$array[$j,$i];
}
}
fisher_yates_shuffle( \@array ); # permutes @array in place
but what I'd really like to know is there a way to do the Fisher-Yates
shuffle in XSLT/eXSLT?
-Lloyd
dcarr at sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org
More information about the kw-pm
mailing list