[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Some table extensions
- From: "David Hall" <dlwh@...>
- Date: Sat, 29 Nov 2003 18:15:49 -0600
I just realized that table.foreach and its cousin wasn't quite as
complete as I would like. I thought someone might find these simple,
(somewhat tested) extensions useful. (No guarantee that it works blah
blah blah don't sue me if it screws up your system)
ext = {}
-- foreach that can have extra arguments
function ext.foreach (tbl, f, ...)
table.foreach(tbl, function (i,v) f(i,v,unpack(arg)) end)
end
-- foreach for methods with extra args
function ext.mforeach(tbl,m,...)
table.foreach(tbl,function (i,v) m(v,unpack(arg)) end)
end
-- foreachi with extra args
function ext.foreachi (tbl, f, ...)
table.foreachi(tbl,function (i,v) f(i,v,unpack(arg)) end)
end
-- foreachi for methods with extra args
function ext.mforeachi(tbl,m,...)
table.foreachi(tbl,function (i,v) m(v,unpack(arg)) end)
end
--
David Hall
den uparchei kanena koutali