Module set

Set implementation for Lua

Functions

intersection (t, other) Compute the set intersection between two tables.
union (t, other) Compute the set union of two tables.
difference (t, other) Compute the (non-symmetric) difference of two tables.
symmetric_difference (t, other) Compute the symmetric difference of two tables.
issubset (t, other) Returns a boolean indicating whether the first table is a subset of the second.
isdisjoint (t, other) Returns a boolean indicating whether the first table is disjoint with respect to the second.
equal (t, other) Returns a boolean indicating whether the first table is equal to the second.
makeset (input) Create a new Set object that allows the set methods from this module to be called directly on the set.


Functions

intersection (t, other)
Compute the set intersection between two tables.

Parameters:

  • t A table
  • other Another table

Returns:

    A new table which contains the intersection between the two tables
union (t, other)
Compute the set union of two tables.

Parameters:

  • t A table
  • other Another table

Returns:

    A new table which contains the union of the two tables
difference (t, other)
Compute the (non-symmetric) difference of two tables.

Parameters:

  • t A table
  • other Another table

Returns:

    A new table which contains the difference between the two tables
symmetric_difference (t, other)
Compute the symmetric difference of two tables.

Parameters:

  • t A table
  • other Another table

Returns:

    A new table which contains the symmetric difference between the two tables
issubset (t, other)
Returns a boolean indicating whether the first table is a subset of the second.

Parameters:

  • t A table
  • other Another table

Returns:

    A boolean value
isdisjoint (t, other)
Returns a boolean indicating whether the first table is disjoint with respect to the second.

Parameters:

  • t A table
  • other Another table

Returns:

    A boolean value
equal (t, other)
Returns a boolean indicating whether the first table is equal to the second.

Parameters:

  • t A table
  • other Another table

Returns:

    A boolean value
makeset (input)
Create a new Set object that allows the set methods from this module to be called directly on the set. The set itself is a table, where the keys are the values contained in the set, and the values are the boolean value `true`. The returned Set object will also have a `tostring()` method that prints the values contained.

Parameters:

  • input An input value to initialize the set with. If this is a Set instance, then it will properly take the value of the set - otherwise, the input is assumed to be a list-like table, and the values in this table are added to the set.
generated by LDoc 1.3.12