added table reverse

This commit is contained in:
Scott E. Graves 2022-07-29 22:25:56 -05:00
parent deb24f2f3c
commit 13eb4cf3b9

View File

@ -10,3 +10,14 @@ end
function table.print_table(o) function table.print_table(o)
return print(vim.inspect(o)) return print(vim.inspect(o))
end end
function table.reverse(self)
local n = #self
local i = 1
while i < n do
self[i], self[n] = self[n], self[i]
i = i + 1
n = n - 1
end
return self
end