Created
January 26, 2016 16:59
-
-
Save max1220/fdeeb5963677f070f00e to your computer and use it in GitHub Desktop.
Simple table reverse with O(n/2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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