26 lines
592 B
Plaintext
26 lines
592 B
Plaintext
include "NSLog.incl"
|
|
|
|
void local fn KnuthShuffle( mutArr as CFMutableArrayRef )
|
|
NSUInteger i, j, count
|
|
|
|
count = len(mutArr)
|
|
for i = count-1 to 1 step -1
|
|
j = rnd(i+1)-1
|
|
MutableArrayExchangeObjects( mutArr, i, j )
|
|
next
|
|
end fn
|
|
|
|
randomize
|
|
|
|
CFMutableArrayRef mutArr
|
|
NSUInteger i
|
|
mutArr = fn MutableArrayWithObjects( @0, @1, @2, @3, @4, @5, @6, @7, @8, @9, NULL )
|
|
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
|
|
|
|
for i = 1 to 100
|
|
fn KnuthShuffle( mutArr )
|
|
NSLog( @"%@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
|
|
next
|
|
|
|
HandleEvents
|