[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reverse
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 1 Aug 2014 21:00:14 +0200
2014-08-01 20:20 GMT+02:00 Thiago L. <fakedme@gmail.com>:
>
> What about tables?
>
Not too hard to do in Lua itself.
function reverse(tbl)
local k,n=1,#tbl
while k<n do
tbl[k],tbl[n] = tbl[n],tbl[k]
k,n = k+1,n-1
end
end
Under the new dispensation, with metamethods respected,
I even doubt whether doing it in Lua takes much of
a performance hit.