Skip to content

Instantly share code, notes, and snippets.

@max1220
Created January 26, 2016 16:59
Show Gist options
  • Save max1220/fdeeb5963677f070f00e to your computer and use it in GitHub Desktop.
Save max1220/fdeeb5963677f070f00e to your computer and use it in GitHub Desktop.
Simple table reverse with O(n/2)
function reverse(tbl)
for i=1, math.floor(#tbl / 2) do
local tmp = tbl[i]
tbl[i] = tbl[#tbl - i + 1]
tbl[#tbl - i + 1] = tmp
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment