todas elas NÃO FUNCIONARAM nas suas totalidades
Your expectation is wrong.
All the above functions do what they are expected to do.
We can not expect that random number generators generate "every" number in a series. Also they may generate duplicates.
It is for us (the programmer) to use the random function to get what we want.
For example, if we want a function to generate every number between 1 to 999 without repeating then we can try this approach.
- Code: Select all Expand view RUN
function RandomList
local aList := Array( 999 )
local nAt, aRandom := {}
AEval( aList, { |u,i| aList[ i ] := i } )
do while Len( aList ) > 0
nAt := HB_RandomInt( 1, Len( aList ) )
AAdd( aRandom, aList[ nAt ] )
ADel( aList, nAt, .t. )
enddo
XBROWSER aRandom SHOW RECID
return nil
This function gives a list of randomly generated list of numbers from 1 to 999 without repeating and covering all numbers.