in reply to Re^2: Non-Repetitive Random Numbers
in thread Non-Repetitive Random Numbers
Keys of a hash are always unique, in my code collisions of random numbers are simply ignored.
> That doesn't guarantee unique values.
maybe this is clearer:
DB<107> $seen{int rand 10}=1 for 1 .. 1000000 => "" DB<108> keys %seen => (6, 3, 7, 9, 2, 8, 1, 4, 0, 5)
Otherwise thats a good occasion to use shuffle or pushing into an array (but this implies reseeding rand every time)
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Non-Repetitive Random Numbers
by BrowserUk (Patriarch) on Apr 05, 2013 at 15:24 UTC |