Knuth shuffle: Difference between revisions

Content added Content deleted
Line 2,180: Line 2,180:
count = len(mutArr)
count = len(mutArr)
for i = 0 to count -1
for i = count-1 to 1 step -1
cln j = arc4random_uniform(i);
j = rnd(i+1)-1
MutableArrayExchangeObjects( mutArr, i, j )
MutableArrayExchangeObjects( mutArr, i, j )
next
next
Line 2,190: Line 2,190:
CFMutableArrayRef mutArr
CFMutableArrayRef mutArr
NSUInteger i
NSUInteger i
mutArr = fn MutableArrayWithObjects( @0, @1, @2, @3, @4, @5, @6, @7, @8, @9 )
mutArr = fn MutableArrayWithObjects( @0, @1, @2, @3, @4, @5, @6, @7, @8, @9, NULL )
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )