Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: randomly choosing elements from an array

by msh210 (Monk)
on Sep 02, 2015 at 21:25 UTC ( [id://1140839]=note: print w/replies, xml ) Need Help??


in reply to Re: randomly choosing elements from an array
in thread randomly choosing elements from an array

This would seem to disallow duplicate choices:
my @items; while (1) { my $item = $a[ rand @a ]; push @items, $item unless $item ~~ @items; last if $n <= @items; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-19 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found