Comparison

util/set.lua @ 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
parent 4544:316e2b09a562
child 5776:bd0ff8ae98a8
child 5813:c888f548876b
comparison
equal deleted inserted replaced
4907:32b638a8da5b 4908:8c5b5ebaacb0
24 end 24 end
25 function set_mt.__div(set, func) 25 function set_mt.__div(set, func)
26 local new_set, new_items = _M.new(); 26 local new_set, new_items = _M.new();
27 local items, new_items = set._items, new_set._items; 27 local items, new_items = set._items, new_set._items;
28 for item in pairs(items) do 28 for item in pairs(items) do
29 if func(item) then 29 local new_item = func(item);
30 new_items[item] = true; 30 if new_item ~= nil then
31 new_items[new_item] = true;
31 end 32 end
32 end 33 end
33 return new_set; 34 return new_set;
34 end 35 end
35 function set_mt.__eq(set1, set2) 36 function set_mt.__eq(set1, set2)