aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-03-29 13:50:59 +0100
committerMatthew Wild <mwild1@gmail.com>2009-03-29 13:50:59 +0100
commitcb2b5ec86f2949720c642a729cdc292a255811c0 (patch)
treee3dd2b48097a92db9fbe488060abe3c689a6f547 /util
parent5ce49a3b6ca80f275df63bd4099e7f0efd9a2733 (diff)
downloadprosody-cb2b5ec86f2949720c642a729cdc292a255811c0.tar.gz
prosody-cb2b5ec86f2949720c642a729cdc292a255811c0.zip
util.array: Add :reverse() method
Diffstat (limited to 'util')
-rw-r--r--util/array.lua8
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