Jump to content

Knuth shuffle: Difference between revisions

m
Line 2,177:
 
void local fn KnuthShuffle( mutArr as CFMutableArrayRef )
NSUInteger i, j, count
 
count = len(mutArr)
for i = 0 to count -1
j = rnd( i + 1 )
MutableArrayExchangeObjects( mutArr, i, j )
next
end fn
 
Line 2,189:
 
CFMutableArrayRef mutArr
mutArr = fn MutableArrayWithObjectsMutableArrayWithArray( @[@0, @1, @2, @3, @4, @5, @6, @7, @8, @9] )
NSUInteger i
mutArr = fn MutableArrayWithObjects( @0, @1, @2, @3, @4, @5, @6, @7, @8, @9 )
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
fn KnuthShuffle( mutArr )
416

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.