kindly/set

Types

A JavaScript Set type.

Unlike gleam/set, a JavaScript Set is mutable, and order is preserved; however, no functions in this module mutate the given Set.

TODO: Note JS Set behaviour for comparisons (SameValueZero, objects are compared by reference, not by value) - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set

pub type Set(a)

Values

pub fn any(in xs: Set(a), satisfying f: fn(a) -> Bool) -> Bool

TODO: rm

Returns True if the given function returns True for any member in the given Set.

If the function returns True for any member, the rest of the Set isn’t checked.

pub fn contains(in xs: Set(a), this x: a) -> Bool

Determines whether a Set contains the given member.

pub fn delete(from xs: Set(a), this x: a) -> Set(a)

Removes a member from the given Set.

If the member isn’t present, the Set is unchanged.

pub fn difference(from xs: Set(a), minus ys: Set(a)) -> Set(a)

Creates a new Set containing any members from the first given Set that aren’t present in the second.

pub fn from_list(xs: List(a)) -> Set(a)

Creates a new Set with members from the given List, preserving order.

pub fn insert(into xs: Set(a), this x: a) -> Set(a)

Inserts a member into the given Set.

If the member is already present, the Set is unchanged.

pub fn intersection(of xs: Set(a), and ys: Set(a)) -> Set(a)

Creates a new Set containing any members present in both given sets.

pub fn is_disjoint(xs: Set(a), from ys: Set(a)) -> Bool

Determines whether the given sets have no common members.

pub fn is_empty(xs: Set(a)) -> Bool

Determines whether the given Set is empty.

pub fn is_subset(xs: Set(a), of ys: Set(a)) -> Bool

Determines whether a Set is fully contained by another.

pub fn new() -> Set(a)

Creates a new empty Set.

pub fn size(xs: Set(a)) -> Int

Gets the number of members in the given Set.

pub fn to_list(xs: Set(a)) -> List(a)

Converts the Set into a List of its members, preserving order.

pub fn union(of xs: Set(a), and ys: Set(a)) -> Set(a)

Creates a new Set containing all members from both given sets.

Search Document