Reference

Set

New

Input A list of elements.
Output A set containing the list of elements.

Signature

set_new(a: List): Set

Example

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): Set

Example

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): Set

Example

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): Set

Example

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): Set

Example

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): Set

Example

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): Boolean

Example

set_contains(set_new([1, 2, 3]), 2) // returns true

Is Disjoint

Input Two sets.
Output True if the sets have no common elements, false otherwise.

Signature

set_isDisjoint(a: Set, b: Set): Boolean

Example

set_isDisjoint(set_new([1, 2]), set_new([3, 4])) // returns true

Is Empty

Input A set.
Output True if the set is empty, false otherwise.

Signature

set_isEmpty(a: Set): Boolean

Example

set_isEmpty(set_new([])) // returns true

Is Not Empty

Input A set.
Output True if the set is not empty, false otherwise.

Signature

set_isNotEmpty(a: Set): Boolean

Example

set_isNotEmpty(set_new([1, 2])) // returns true

Is 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): Boolean

Example

set_isSubset(set_new([1, 2]), set_new([1, 2, 3])) // returns true

Is 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): Boolean

Example

set_isSuperset(set_new([1, 2, 3]), set_new([1, 2])) // returns true

Length

Input A set.
Output The number of elements in the set.

Signature

set_length(a: Set): Number

Example

set_length(set_new([1, 2, 3])) // returns 3