abbandoning Lua... Error in runtime

This commit is contained in:
n0ffie 2025-01-10 14:21:27 +01:00
parent cafced2917
commit 54703852e7
20 changed files with 1119 additions and 164 deletions

View file

@ -0,0 +1,25 @@
local bubble_sort = Future:new()
function bubble_sort:poll(array)
local n = array:size()
self.state[n] = self.state[n] or n
if n == 0 then
return false
end
local swapped = false
for i = 1, n - 1 do
if array.at(i-1) > array.at(i) then
array.swap(i-1, i)
swapped = true
end
end
self.state.n = self.state.n - 1
return not swapped
end
function make_available(sorter_list)
table.insert(sorter_list, "bubble_sort")
end