in reply to
Re: Re: random number
in thread random number
#splice is still O(n)
$array[$index] = $array[-1];
True. And that's a neat solution.
It would still be better to shuffle the array and simply pop the next one when you need it as was suggested at near the top of the thread.
Examine what is said, not who speaks.
A Programming Language, 1962
Programming the 1900 series in COBOL, 1974
Algorithms + Data Structures = Programs, 1976
The C Programming Language, 1978
System V - Interface definition, 1986
Z80 Assembly Language Programming, 1979
TheSOURCE User's Manual, 1979
The C Primer, 1983
Interactive Fortran 77, A Hands on Approach, 1984
Perl.1 man page, 1991
Results (343 votes),