Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^6: About List::Util's pure Perl shuffle()

by blazar (Canon)
on Jul 13, 2007 at 13:29 UTC ( #626432=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub naive (@) {
        for (reverse 1..$#_) {
    ...
            @_[$_,$r]=@_[$r,$_];
        }
    }
    
  2. or download this
    sub bzr (@) {
        my @a = 0..$#_;
    ...
        my $n;
        map +($_[$a[$n=rand($i--)]], $a[$n]=$a[$i])[0], @_;
    }
    
  3. or download this
            my $x = $l[$r];
            $l[$r] = $l[$_];
            $l[$_] = $x;
    
  4. or download this
    sub naive2 (@) {
        my @l=@_;
    ...
        }
        @l2;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://626432]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-30 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls