Std.Set
Immutable sets backed by Erlang's sets module (version 2).
Functions
new
fun new : Unit -> Set aCreates an empty set.
from_list
fun from_list : (items: List a) -> Set a where {a: Eq}Creates a set from a list of elements.
to_list
fun to_list : (set: Set a) -> List aReturns the elements as a list.
insert
fun insert : (elem: a) -> (set: Set a) -> Set a where {a: Eq}Inserts an element into the set.
remove
fun remove : (elem: a) -> (set: Set a) -> Set a where {a: Eq}Removes an element from the set. Returns the set unchanged if not present.
member
fun member : (elem: a) -> (set: Set a) -> Bool where {a: Eq}Returns True if the element is in the set.
size
fun size : (set: Set a) -> IntReturns the number of elements in the set.
is_empty
fun is_empty : Set a -> BoolReturns True if the set has no elements.
union
fun union : (a: Set a) -> (b: Set a) -> Set a where {a: Eq}Returns the union of two sets.
intersection
fun intersection : (a: Set a) -> (b: Set a) -> Set a where {a: Eq}Returns the intersection of two sets.
difference
fun difference : (a: Set a) -> (b: Set a) -> Set a where {a: Eq}Returns elements in the first set but not the second.
symmetric_difference
fun symmetric_difference : (a: Set a) -> (b: Set a) -> Set a where {a: Eq}Returns elements in either set but not both.
is_subset
fun is_subset : (sub: Set a) -> (super: Set a) -> Bool where {a: Eq}Returns True if the first set is a subset of the second.
map
fun map : (f: a -> b) -> (set: Set a) -> Set b where {b: Eq}Applies a function to every element, returning a new set.
filter
fun filter : (pred: a -> Bool) -> (set: Set a) -> Set aReturns a set containing only elements where the predicate returns True.
fold
fun fold : (f: b -> a -> b) -> (init: b) -> (set: Set a) -> bFolds over all elements.