The iiris/set module includes functions for working with Sets. It is
designed to be imported with a wildcard, e.g.
import * as S from 'iiris/array'<T>(value: T) => (set: Set<T>) => Set<T>Return a copy of set with value.
- If
setalready containsvalue, it is returned unchanged.
S.add(4, S.from([1, 2, 3]))
// => Set(4) { 1, 2, 3, 4 }<T>(value: T) => (set: Set<T>) => Set<T>Return a copy of set without value.
- If
setdoesn't containvalue, it is returned unchanged.
S.remove(1, S.from([1, 2, 3]))
// => Set(2) { 2, 3 }<T>() => Set<T>Create an empty set.
S.empty()
// => Set(0) {}<T>(iterable: Iterable<T>) => Set<T>Convert an iterable into a set.
S.from([1, 2, 3])
// => Set(3) { 1, 2, 3 }<T>(value: T) => Set<T>Create a singleton set containing value.
S.singleton(1)
// => Set(1) { 1 }<T>(value: T) => (set: Set<T>) => booleanCheck if set contains value.
S.has(1, S.from([1, 2, 3]))
// => true<T>(set: Set<T>) => booleanCheck if the set is empty.
S.isEmpty(S.empty())
// => true<T>(first: Set<T>) => (second: Set<T>) => Set<T>Calculate the difference between two sets.
S.difference(S.from([1, 2, 3]), S.from([2, 3, 4]))
// => Set(4) { 1 }See also: intersection, union
<T>(first: Set<T>) => (second: Set<T>) => Set<T>Calculate the intersection between two sets.
S.intersection(S.from([1, 2, 3]), S.from([2, 3, 4]))
// => Set(4) { 2, 3 }See also: intersection, union
<T>(first: Set<T>) => (second: Set<T>) => Set<T>Calculate the union between two sets.
S.union(S.from([1, 2, 3]), S.from([2, 3, 4]))
// => Set(4) { 1, 2, 3, 4 }See also: difference, intersection