Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,26 @@
|
|||
local n = #arg
|
||||
assert(n >= 2, "There must be at least two arguments passed.")
|
||||
local list = arg:mapped(|a| -> tonumber(a)):reorder()
|
||||
if #list != n or !list:checkall(|e| -> math.round(e) == e and e >= 0) then
|
||||
error("All arguments must be non-negative integers.")
|
||||
end
|
||||
local max = list:max()
|
||||
local cos = table.create(max + 1)
|
||||
print($"Before: {list:concat(" ")}")
|
||||
for list as i do
|
||||
local function sleep_sort(j)
|
||||
os.sleep(1000)
|
||||
coroutine.yield(j)
|
||||
end
|
||||
cos[i + 1] = coroutine.create(sleep_sort)
|
||||
end
|
||||
io.write("After : ")
|
||||
for i = 0, max do
|
||||
local co = cos[i + 1]
|
||||
if co then
|
||||
local _, v = coroutine.resume(co, i)
|
||||
io.write($"{v} ")
|
||||
io.output():flush()
|
||||
end
|
||||
end
|
||||
print()
|
||||
Loading…
Add table
Add a link
Reference in a new issue