Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
We don't bite newbies here... much
 
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 studying the Monastery: (8)
As of 2014-04-20 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls