Reference
Set
New
| Input | A list of elements. |
|---|---|
| Output | A set containing the list of elements. |
Signature
set_new(a: List): SetExample
set_new([1, 2, 3]) // returns {1, 2, 3}Add
| Input | A set and a hashable element. |
|---|---|
| Output | A new set containing the element. |
Signature
set_add(a: Set, b: Hashable): SetExample
set_add(set_new([1, 2]), 3) // returns {1, 2, 3}Remove
| Input | A set and a hashable element. |
|---|---|
| Output | A new set without the element. |
Signature
set_remove(a: Set, b: Hashable): SetExample
set_remove(set_new([1, 2, 3]), 2) // returns {1, 3}Union
| Input | Two sets. |
|---|---|
| Output | A new set containing all elements from both sets. |
Signature
set_union(a: Set, b: Set): SetExample
set_union(set_new([1, 2]), set_new([2, 3])) // returns {1, 2, 3}Intersection
| Input | Two sets. |
|---|---|
| Output | A new set containing only elements that are in both sets. |
Signature
set_intersection(a: Set, b: Set): SetExample
set_intersection(set_new([1, 2, 3]), set_new([2, 3, 4])) // returns {2, 3}Difference
| Input | Two sets. |
|---|---|
| Output | A new set containing elements from the first set that are not in the second set. |
Signature
set_difference(a: Set, b: Set): SetExample
set_difference(set_new([1, 2, 3]), set_new([2, 3])) // returns {1}Contains
| Input | A set and a hashable element. |
|---|---|
| Output | True if the set contains the element, false otherwise. |
Signature
set_contains(a: Set, b: Hashable): BooleanExample
set_contains(set_new([1, 2, 3]), 2) // returns trueIs Disjoint
| Input | Two sets. |
|---|---|
| Output | True if the sets have no common elements, false otherwise. |
Signature
set_isDisjoint(a: Set, b: Set): BooleanExample
set_isDisjoint(set_new([1, 2]), set_new([3, 4])) // returns trueIs Empty
| Input | A set. |
|---|---|
| Output | True if the set is empty, false otherwise. |
Signature
set_isEmpty(a: Set): BooleanExample
set_isEmpty(set_new([])) // returns trueIs Not Empty
| Input | A set. |
|---|---|
| Output | True if the set is not empty, false otherwise. |
Signature
set_isNotEmpty(a: Set): BooleanExample
set_isNotEmpty(set_new([1, 2])) // returns trueIs Subset
| Input | Two sets. |
|---|---|
| Output | True if the first set is a subset of the second set, false otherwise. |
Signature
set_isSubset(a: Set, b: Set): BooleanExample
set_isSubset(set_new([1, 2]), set_new([1, 2, 3])) // returns trueIs Superset
| Input | Two sets. |
|---|---|
| Output | True if the first set is a superset of the second set, false otherwise. |
Signature
set_isSuperset(a: Set, b: Set): BooleanExample
set_isSuperset(set_new([1, 2, 3]), set_new([1, 2])) // returns trueLength
| Input | A set. |
|---|---|
| Output | The number of elements in the set. |
Signature
set_length(a: Set): NumberExample
set_length(set_new([1, 2, 3])) // returns 3