aboutsummaryrefslogtreecommitdiffstats
path: root/util/set.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/set.lua')
-rw-r--r--util/set.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/util/set.lua b/util/set.lua
index 5f7a9ae2..7f45526e 100644
--- a/util/set.lua
+++ b/util/set.lua
@@ -1,12 +1,12 @@
-- Prosody IM
--- Copyright (C) 2008-2009 Matthew Wild
--- Copyright (C) 2008-2009 Waqas Hussain
+-- Copyright (C) 2008-2010 Matthew Wild
+-- Copyright (C) 2008-2010 Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--
-local ipairs, pairs, setmetatable, next, tostring =
+local ipairs, pairs, setmetatable, next, tostring =
ipairs, pairs, setmetatable, next, tostring;
local t_concat = table.concat;
@@ -26,8 +26,9 @@ function set_mt.__div(set, func)
local new_set, new_items = _M.new();
local items, new_items = set._items, new_set._items;
for item in pairs(items) do
- if func(item) then
- new_items[item] = true;
+ local new_item = func(item);
+ if new_item ~= nil then
+ new_items[new_item] = true;
end
end
return new_set;
@@ -82,8 +83,10 @@ function new(list)
end
function set:add_list(list)
- for _, item in ipairs(list) do
- items[item] = true;
+ if list then
+ for _, item in ipairs(list) do
+ items[item] = true;
+ end
end
end