Knuth shuffle: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Add SETL)
Line 4,738: Line 4,738:
[8,9,7,3,4,5,1,2,6]
[8,9,7,3,4,5,1,2,6]
</pre>
</pre>

=={{header|SETL}}==
<syntaxhighlight lang="setl">program knuth_shuffle;
setrandom(0);

array := [1..10];
print("Before shuffling:", array);
shuffle(array);
print("After shuffling: ", array);

proc shuffle(rw tup);
loop for i in [1..#tup-1] do
j := random [i+1..#tup];
[tup(i), tup(j)] := [tup(j), tup(i)];
end loop;
end proc;
end program;</syntaxhighlight>
{{out}}
<pre>Before shuffling: [1 2 3 4 5 6 7 8 9 10]
After shuffling: [7 8 1 10 2 5 6 9 4 3]</pre>


=={{header|Sidef}}==
=={{header|Sidef}}==