Provided by: erlang-manpages_20.2.2+dfsg-1ubuntu2_all

**NAME**

sets - Functions for set manipulation.

**DESCRIPTION**

Sets are collections of elements with no duplicate elements. The representation of a set is undefined. This module provides the same interface as theordsets(3erl)module but with an undefined representation. One difference is that while this module considers two elements as different if they do not match (=:=),ordsetsconsiders two elements as different if and only if they do not compare equal (==).

**DATA** **TYPES**

set(Element)As returned bynew/0.set()=set(term())

**EXPORTS**

add_element(Element,Set1)->Set2Types: Set1 = Set2 =set(Element) Returns a new set formed fromSet1withElementinserted.del_element(Element,Set1)->Set2Types: Set1 = Set2 =set(Element) ReturnsSet1, but withElementremoved.filter(Pred,Set1)->Set2Types: Pred = fun((Element) -> boolean()) Set1 = Set2 =set(Element) Filters elements inSet1with boolean functionPred.fold(Function,Acc0,Set)->Acc1Types: Function = fun((Element, AccIn) -> AccOut) Set =set(Element) Acc0 = Acc1 = AccIn = AccOut = Acc FoldsFunctionover every element inSetand returns the final value of the accumulator. The evaluation order is undefined.from_list(List)->SetTypes: List = [Element] Set =set(Element) Returns a set of the elements inList.intersection(SetList)->SetTypes: SetList = [set(Element), ...] Set =set(Element) Returns the intersection of the non-empty list of sets.intersection(Set1,Set2)->Set3Types: Set1 = Set2 = Set3 =set(Element) Returns the intersection ofSet1andSet2.is_disjoint(Set1,Set2)->boolean()Types: Set1 = Set2 =set(Element) ReturnstrueifSet1andSet2are disjoint (have no elements in common), otherwisefalse.is_element(Element,Set)->boolean()Types: Set =set(Element) ReturnstrueifElementis an element ofSet, otherwisefalse.is_set(Set)->boolean()Types: Set = term() ReturnstrueifSetis a set of elements, otherwisefalse.is_subset(Set1,Set2)->boolean()Types: Set1 = Set2 =set(Element) Returnstruewhen every element ofSet1is also a member ofSet2, otherwisefalse.new()->set()Returns a new empty set.size(Set)->integer()>=0Types: Set =set()Returns the number of elements inSet.subtract(Set1,Set2)->Set3Types: Set1 = Set2 = Set3 =set(Element) Returns only the elements ofSet1that are not also elements ofSet2.to_list(Set)->ListTypes: Set =set(Element) List = [Element] Returns the elements ofSetas a list. The order of the returned elements is undefined.union(SetList)->SetTypes: SetList = [set(Element)] Set =set(Element) Returns the merged (union) set of the list of sets.union(Set1,Set2)->Set3Types: Set1 = Set2 = Set3 =set(Element) Returns the merged (union) set ofSet1andSet2.

**SEE** **ALSO**

gb_sets(3erl),ordsets(3erl)