Module:Set/doc

This module includes a number of set operations for Lua tables. It currently has union, intersection and complement functions for both key/value pairs and for values only. It is a meta-module, meant to be called from other Lua modules, and should not be called directly from #invoke.

Loading the module
To use any of the functions, first you must load the module.

union
Returns the union of the key/value pairs of n tables. If any of the tables contain different values for the same table key, the table value is converted to an array holding all of the different values. For example, for the tables  and , union will return. An error is raised if the function receives less than two tables as arguments.

valueUnion
Returns the union of the values of n tables, as an array. For example, for the tables  and , valueUnion will return. An error is raised if the function receives less than two tables as arguments.

intersection
Returns the intersection of the key/value pairs of n tables. Both the key and the value must match to be included in the resulting table. For example, for the tables  and , intersection will return. An error is raised if the function receives less than two tables as arguments.

valueIntersection
Returns the intersection of the values of n tables, as an array. For example, for the tables  and , valueIntersection will return. An error is raised if the function receives less than two tables as arguments.

complement
Returns the relative complement of,  , ..., in. The complement is of key/value pairs. This is equivalent to all the key/value pairs that are in  but are not in any of ,  , ...  . For example, for the tables   and  , complement would return. An error is raised if the function receives less than two tables as arguments.

valueComplement
This returns an array containing the relative complement of,  , ..., in. The complement is of values only. This is equivalent to all the values that are in tn but are not in t1, t2, ... tn-1. For example, for the tables,   and  , valueComplement would return. An error is raised if the function receives less than two tables as arguments.