Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Knuth-shuffle/CLU/knuth-shuffle.clu
Normal file
21
Task/Knuth-shuffle/CLU/knuth-shuffle.clu
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
knuth_shuffle = proc [T: type] (a: array[T])
|
||||
lo: int := array[T]$low(a)
|
||||
hi: int := array[T]$high(a)
|
||||
for i: int in int$from_to_by(hi, lo+1, -1) do
|
||||
j: int := lo + random$next(i-lo+1)
|
||||
temp: T := a[i]
|
||||
a[i] := a[j]
|
||||
a[j] := temp
|
||||
end
|
||||
end knuth_shuffle
|
||||
|
||||
start_up = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
d: date := now()
|
||||
random$seed(d.second + 60*(d.minute + 60*d.hour))
|
||||
arr: array[int] := array[int]$[1,2,3,4,5,6,7,8,9]
|
||||
knuth_shuffle[int](arr)
|
||||
for i: int in array[int]$elements(arr) do
|
||||
stream$puts(po, int$unparse(i) || " ")
|
||||
end
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue