Knuth shuffle: Difference between revisions

(→‎{{header|RPL}}: formatting)
Line 4,444:
DUP SIZE 2 '''FOR''' j
j RAND * FLOOR 1 +
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> ''( { list } -- { list} )'' <span style="color:grey">// works also with [ arrays ]</span>
for j from last downto 2 do:
let k = random integer in range 1 ≤ j ≤ i
1,150

edits