I will make an effort to interpret BrowserUKs terse comment for you :-)
In grepGen/mapGen/smartGen you have a redo in the event of a collision, whereas if you really want unique random numbers, they could be generated much more simply by the shuffle method he suggested. His method does not involve repeated retries and removes the need for any of these functions. His one liner does what each of the three methods you proposed does, but much more efficiently....
my @rands = ( shuffle # shuffle, like a pack of cards 1 .. 120 # a series of numbers from 1..120 ) [ 0 .. 99 ]; # take the first 100 of these # the resulting @rands is a 100 element array of numbers # in the range 1..120, all of which are unique
In reply to Re^3: Curious find while comparing grep, map, and smart match...
by space_monk
in thread Curious find while comparing grep, map, and smart match...
by dbuckhal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |