Hi Monks
I need to generate non-repetitive random numbers. I have looked into the rand() function but it gives repeating numbers. Searching for answers I came across script which implements it through a hash which is as follows:
sub rand_sam { my ($n,@n) = (shift,@_); return 0 unless ($n < scalar @n); my %seen = (); until (keys %seen == $samples) { $seen{$pop[rand @pop]}=1; } return(keys %seen); }
But could not understand the script. Please suggest ways to efficiently generate non repetitive random numbers(from 0 to 100000)..
THnx..
In reply to Non-Repetitive Random Numbers by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |