RosettaCodeData/Task/Knuth-shuffle/SenseTalk/knuth-shuffle.sensetalk
2023-07-01 13:44:08 -04:00

9 lines
311 B
Text

set list to 1..9 -- a range, will become a list as needed
set last to the number of items in list
repeat with i = last down to 2 -- in SenseTalk, the first index in a list is 1
set j = random (1,i-1)
set [item i of list, item j of list] to [item j of list, item i of list] -- swap items
end repeat
put list