Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Randomize an array

by Anonymous Monk
on Jul 01, 2008 at 20:57 UTC ( #695028=note: print w/replies, xml ) Need Help??


in reply to Re: Randomize an array
in thread Randomize an array

That code does not work.

Replies are listed 'Best First'.
Re^3: Randomize an array
by psini (Deacon) on Jul 01, 2008 at 21:03 UTC

    Are you sure?

    #!/usr/bin/perl # use strict; use warnings; my @array=0..100; @array=sort { (-1,0,1)[rand 3] } @array; print join(',',@array),"\n";
    sini@ordinalfabetix:~$ ./x.pl 70,61,28,24,5,52,41,57,21,53,82,10,34,86,29,12,46,2,0,1,56,14,47,4,3,6 +,58,8,7,20,9,72,17,11,13,18,68,25,55,22,67,54,23,15,90,16,19,40,42,43 +,59,30,65,36,60,27,95,76,62,88,31,66,26,33,32,38,37,35,64,50,39,44,69 +,45,81,51,63,74,49,48,77,84,87,94,71,80,79,73,83,75,85,78,89,92,91,93 +,98,99,96,100,97 sini@ordinalfabetix:~$

    Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2019-05-26 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (153 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!