#cp.collect.Set
An implementation of a logical set
, which contains a single unique reference of each item in it. For example:
You can combine sets in a couple of ways. For example, a union
:
...or an intersection
:
As indicated above, you can use operators for common set operations. Specifically:
- union (A ⋃ B):
a | b
ora + b
- intersection (A ∩ B):
a & b
- complement (Ac):
-a
- difference (A - B):
a - b
- symetric difference (A ⊕ B)
a ~ b
Keep in mind that Lua's operator precedence may be different to that of standard set operations, so it's probably best to group operations in brackets if you combine more than one in a single statement. For example:
#API Overview
Constants - Useful values which cannot be changed
Functions - API calls offered directly by the extension
Constructors - API calls which return an object, typically one that offers API methods
Methods - API calls which can only be made on an object returned by a constructor
#API Documentation
#Constants
#Functions
#Constructors
| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | Signature | cp.collect.Set.fromList(list) -> cp.collect.Set
| | Type | Constructor | | Description | Creates a new Set
instance, containing the unique items in the table collected as a list from 1
to n
. Any duplicate items will only occur in the Set
once. | | Parameters |
- list - The table that contains items as a list to add to the
Set
. E.g.{"foo", "bar"}</li></ul> | | **Returns** | <ul><li>The new
Set`.