Software /
code /
prosody
Comparison
util/array.lua @ 1371:9e45bdf55353
util.array: Add array:append() method, to append a new array to an existing one
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 20 Jun 2009 22:43:54 +0100 |
parent | 1027:fe2e3d3dba6a |
child | 1372:3b13bb57002e |
comparison
equal
deleted
inserted
replaced
1370:3a467e6885f0 | 1371:9e45bdf55353 |
---|---|
50 self:push(self[i]); | 50 self:push(self[i]); |
51 self:pop(i); | 51 self:pop(i); |
52 end | 52 end |
53 end | 53 end |
54 | 54 |
55 function array:append(array) | |
56 local len,len2 = #self, #array; | |
57 for i=1,len2 do | |
58 self[len+i] = array[i]; | |
59 end | |
60 return self; | |
61 end | |
62 | |
55 function array.collect(f, s, var) | 63 function array.collect(f, s, var) |
56 local t, var = {}; | 64 local t, var = {}; |
57 while true do | 65 while true do |
58 var = f(s, var); | 66 var = f(s, var); |
59 if var == nil then break; end | 67 if var == nil then break; end |