Knuth shuffle: Difference between revisions
→{{header|FutureBasic}}
Line 2,177:
void local fn KnuthShuffle( mutArr as CFMutableArrayRef )
NSUInteger i, j, count
count = len(mutArr)
for i = 0 to count -1
cln j = arc4random_uniform(i);
MutableArrayExchangeObjects( mutArr, i, j )▼
next▼
▲MutableArrayExchangeObjects( mutArr, i, j )
▲next
end fn
Line 2,194 ⟶ 2,193:
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
for i = 1 to
fn KnuthShuffle( mutArr )
NSLog( @"%@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
next
|