Provided by: erlang-manpages_16.b.3-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 not defined. This module provides exactly the same interface as the moduleordsetsbut with a defined 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()As returned bynew/0.

**EXPORTS**

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

**SEE** **ALSO**

ordsets(3erl),gb_sets(3erl)