Knuth shuffle: Difference between revisions
m
→{{header|RPL}}: typos, minor code optimization
(→{{header|RPL}}: formatting) |
m (→{{header|RPL}}: typos, minor code optimization) |
||
Line 4,435:
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
Line 4,444:
≪
DUP SIZE 2 '''FOR''' j
j RAND *
DUP2 GET 3 PICK j GET SWAP 4 ROLLD PUT j ROT PUT
-1 '''STEP'''
≫ '<span style="color:blue">KNUTH</span>' STO
|
<span style="color:blue">KNUTH</span> ''( {
for j from last downto 2 do:
let k = random integer in range 1 ≤
swap items[j] with items[k]
|