Knuth shuffle: Difference between revisions
Content added Content deleted
Line 2,177: | Line 2,177: | ||
void local fn KnuthShuffle( mutArr as CFMutableArrayRef ) |
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 |
end fn |
||
Line 2,189: | Line 2,189: | ||
CFMutableArrayRef mutArr |
CFMutableArrayRef mutArr |
||
⚫ | |||
NSUInteger i |
|||
⚫ | |||
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) ) |
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) ) |
||
fn KnuthShuffle( mutArr ) |
fn KnuthShuffle( mutArr ) |