Module pl.Set

A Set class.

Functions

Set (t) create a set.
Set:set (key) add a value to a set.
Set:unset (key) remove a value from a set.
Set:values () get a list of the values in a set.
Set:map (fn, ...) map a function over the values of a set.
Set:union (set) union of two sets (also +).
Set:intersection (set) intersection of two sets (also *).
Set:difference (set) new set with elements in the set that are not in the other (also -).
Set:issubset (set) is the first set a subset of the second?.
Set:issempty () is the set empty?.
Set:isdisjoint (set) are the sets disjoint?


Functions

Set (t)
create a set.

Parameters:

  • t: may be a Set, Map or list-like table.
Set:set (key)
add a value to a set.

Parameters:

  • key: a value
Set:unset (key)
remove a value from a set.

Parameters:

  • key: a value
Set:values ()
get a list of the values in a set.
Set:map (fn, ...)
map a function over the values of a set.

Parameters:

  • fn: a function
  • ...: extra arguments to pass to the function.

Returns:

    a new set
Set:union (set)
union of two sets (also +).

Parameters:

  • set: another set

Returns:

    a new set
Set:intersection (set)
intersection of two sets (also *).

Parameters:

  • set: another set

Returns:

    a new set
Set:difference (set)
new set with elements in the set that are not in the other (also -).

Parameters:

  • set: another set

Returns:

    a new set
Set:issubset (set)
is the first set a subset of the second?.

Parameters:

  • set:

Returns:

    true or false
Set:issempty ()
is the set empty?.

Returns:

    true or false
Set:isdisjoint (set)
are the sets disjoint? (no elements in common). Uses naive definition, i.e. that intersection is empty

Parameters:

  • set: another set

Returns:

    true or false