Changeset

4908:8c5b5ebaacb0

util.set: Change '/' operator from filter to map+filter (nil to drop from set, false is a valid item). No code found which depends on current behaviour.
author Matthew Wild <mwild1@gmail.com>
date Thu, 24 May 2012 18:51:18 +0100
parents 4907:32b638a8da5b
children 4909:01bfb9a76660
files util/set.lua
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/set.lua	Thu May 24 03:33:14 2012 +0100
+++ b/util/set.lua	Thu May 24 18:51:18 2012 +0100
@@ -26,8 +26,9 @@
 	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;