Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: How much random is rand()?

by merlyn (Sage)
on Jan 19, 2009 at 18:17 UTC ( [id://737364]=note: print w/replies, xml ) Need Help??


in reply to How much random is rand()?

What do you think scalar grep /4/, qw(14) returns?

Yup. The moment you add 14, you can't ever add 4, because it's a subset of 14. So you get "stuck" adding the last few single-digit numbers, because they're already "within" the longer numbers.

You should be looking for shuffle instead. Been done quite a few times here already. For the lazy:

use List::Util qw(shuffle); my @shuffled = shuffle 0..32;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-24 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found