Knuth shuffle: Difference between revisions
m
→{{header|FutureBasic}}
Line 2,182:
for i = 0 to count -1
j = rnd( i + 1 )
if j > count - 1 then j = count - 1
MutableArrayExchangeObjects( mutArr, i, j )
next
Line 2,189 ⟶ 2,190:
CFMutableArrayRef mutArr
NSUInteger i
mutArr = fn
NSLog( @"Before shuffle: %@", fn ArrayComponentsJoinedByString( mutArr, @"" ) )
for i = 1 to 10
fn KnuthShuffle( mutArr )
NSLog( @"
next
HandleEvents
</syntaxhighlight>
{{
<pre>
Before shuffle: 0123456789
1274860395
2715638904
7182035964
1297658403
2916574083
9162507843
1875962034
8721965034
7968402351
9347510862
</pre>
|