Skip to content

Std.Set

opaque type Set[A]

A set of values of type A, ordered by Ord.

fn empty[A]() -> Set[A]

The empty set.

fn from_list[A: Ord](xs: List[A]) -> Set[A]

The set of the values of xs.

fn insert[A: Ord](s: Set[A], x: A) -> Set[A]

s with x.

fn remove[A: Ord](s: Set[A], x: A) -> Set[A]

s without x.

fn contains[A: Ord](s: Set[A], x: A) -> Bool

Whether x is in s.

fn size[A](s: Set[A]) -> Int

The number of values.

fn is_empty[A](s: Set[A]) -> Bool

Whether the set is empty.

fn fold[A, B](s: Set[A], from: B, f: fn(B, A) -> B fails E(f) uses { R(f) }) -> B fails E(f) uses { R(f) }

Folds the values in order, starting from from.

fn each[A](s: Set[A], f: fn(A) -> () fails E(f) uses { R(f) }) -> () fails E(f) uses { R(f) }

Calls f on each value in order. Stops at the first failure.

fn to_list[A](s: Set[A]) -> List[A]

The values in order.

fn filter[A](s: Set[A], f: fn(A) -> Bool fails E(f) uses { R(f) }) -> Set[A] fails E(f) uses { R(f) }

The values for which f is True.

fn union[A: Ord](a: Set[A], b: Set[A]) -> Set[A]

The values of both.