diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-03-29 13:50:59 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-03-29 13:50:59 +0100 |
commit | cb2b5ec86f2949720c642a729cdc292a255811c0 (patch) | |
tree | e3dd2b48097a92db9fbe488060abe3c689a6f547 /util/array.lua | |
parent | 5ce49a3b6ca80f275df63bd4099e7f0efd9a2733 (diff) | |
download | prosody-cb2b5ec86f2949720c642a729cdc292a255811c0.tar.gz prosody-cb2b5ec86f2949720c642a729cdc292a255811c0.zip |
util.array: Add :reverse() method
Diffstat (limited to 'util/array.lua')
-rw-r--r-- | util/array.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/array.lua b/util/array.lua index f1f8fa97..9e99a3ec 100644 --- a/util/array.lua +++ b/util/array.lua @@ -44,4 +44,12 @@ function array:shuffle() end end +function array:reverse() + local len = #self-1; + for i=len,1,-1 do + self:push(self[i]); + self:pop(i); + end +end + _G.array = array |