Module sets
Data Types
set()
abstract datatype: set(Element)
set()
set() = set(term())
Function Index
| add_element/2 | Return Set1 with Element inserted in it. |
| del_element/2 | Return Set1 but with Element removed. |
| filter/2 | Filter Set with Fun. |
| filtermap/2 | Filters and maps elements in Set1 with function Fun. |
| fold/3 | Fold function Fun over all elements in Set and return Accumulator. |
| from_list/1 | Builds a set from the elements in List. |
| from_list/2 | Builds a set from the elements in List using the specified version. |
| intersection/1 | Return the intersection of the list of sets. |
| intersection/2 | Return the intersection of Set1 and Set2. |
| is_disjoint/2 | Check whether Set1 and Set2 are disjoint. |
| is_element/2 | Return true if Element is an element of Set, else false. |
| is_empty/1 | Returns true if Set is an empty set, otherwise false. |
| is_equal/2 | Returns true if Set1 and Set2 are equal, that is when every element of one
set is also a member of the respective other set, otherwise false. |
| is_set/1 | Returns true if Set appears to be a set of elements, otherwise false. |
| is_subset/2 | Return 'true' when every element of Set1 is also a member of Set2, else 'false'. |
| map/2 | Map Set with Fun. |
| new/0 | Returns a new empty set using the v2 format (a map). |
| new/1 | Returns a new empty set (only v2 format is supported). |
| size/1 | Returns the number of elements in Set. |
| subtract/2 | Return all and only the elements of Set1 which are not also in Set2. |
| to_list/1 | Returns the elements of Set as a list. |
| union/1 | Return the union of the list of sets. |
| union/2 | Return the union of Set1 and Set2. |
Function Details
add_element/2
add_element(Element, Set1) -> Set2
Element: the element to addSet1: the set to add the element to
returns: Returns a new set formed from Set1 with Element inserted.
Return Set1 with Element inserted in it.
del_element/2
del_element(Element, Set1) -> Set2
Element: the element to removeSet1: the set to remove the element from
returns: Returns Set1, but with Element removed.
Return Set1 but with Element removed.
filter/2
filter(Pred, Set1) -> Set2
Pred: the boolean function to filter elements withSet1: the set to filter
returns: Returns a set containing elements of Set1 that satisfy the boolean
function Fun. The evaluation order is undefined.
Filter Set with Fun.
filtermap/2
filtermap(Fun, Set1) -> Set2
Fun = fun((Element1) -> boolean() | {true, Element2})Set1 = set(Element1)Set2 = set(Element1 | Element2)
Fun: the filter and map funSet1: the set to filter and map over
returns: Returns a set containing elements of Set1 that are filtered and mapped using Fun.
Filters and maps elements in Set1 with function Fun.
fold/3
fold(Function, Acc0, Set) -> Acc1
Function = fun((Element, AccIn) -> AccOut)Set = set(Element)Acc0 = AccAcc1 = AccAccIn = AccAccOut = Acc
Set: the set to fold over
returns: Returns the final value of the accumulator after folding the function over every element in the set.
Fold function Fun over all elements in Set and return Accumulator.
from_list/1
from_list(List) -> Set
List = [Element]Set = set(Element)
List: the list of items that is used for building the set
returns: Returns a set of the elements in List.
Builds a set from the elements in List.
from_list/2
from_list(List, Version::[{version, 2}]) -> Set
List = [Element]Set = set(Element)
List: the list to be converted to a setVersion: only version 2 is supported
returns: Returns a set of the elements in List at the given version.
Builds a set from the elements in List using the specified version. Only v2
format is supported.
intersection/1
intersection(SetList) -> Set
SetList: the non-empty list of sets
returns: Returns the intersection of the non-empty list of sets.
Return the intersection of the list of sets.
intersection/2
intersection(Set1, Set2) -> Set3
Set1: the first setSet2: the second set
returns: Returns the intersection of Set1 and Set2.
Return the intersection of Set1 and Set2.
is_disjoint/2
is_disjoint(Set1, Set2) -> boolean()
Set1: the first setSet2: the second set
returns: Returns true if Set1 and Set2 are disjoint (have no elements in common),
otherwise false.
Check whether Set1 and Set2 are disjoint.
is_element/2
is_element(Element, Set) -> boolean()
Set = set(Element)
Element: the element to checkSet: the set to check against
returns: Returns true if Element is an element of Set, otherwise false.
Return true if Element is an element of Set, else false.
is_empty/1
is_empty(Set) -> boolean()
Set = set()
Set: the set to be checked for emptiness
returns: Returns true if Set is an empty set, otherwise false.
Returns true if Set is an empty set, otherwise false.
is_equal/2
is_equal(Set1, Set2) -> boolean()
Set1: first set to be checked for equalitySet2: second set to be checked for equality
returns: Return true if Set1 and Set2 contain the same elements, otherwise false.
Returns true if Set1 and Set2 are equal, that is when every element of one
set is also a member of the respective other set, otherwise false.
is_set/1
is_set(Set) -> boolean()
Set = term()
Set: the term that will be checked
returns: Return true if Set is a set of elements, else false.
Returns true if Set appears to be a set of elements, otherwise false.
Note that the test is shallow and will return true for any term that coincides with
the possible representations of a set.
is_subset/2
is_subset(Set1, Set2) -> boolean()
Set1: the first setSet2: the second set
returns: Returns true when every element of Set1 is also a member of Set2,
otherwise false.
Return ‘true’ when every element of Set1 is also a member of Set2, else ‘false’.
map/2
map(Fun, Set1) -> Set2
Fun: the mapping functionSet1: the set to map over
returns: Returns a set containing elements of Set1 that are mapped using Fun.
Map Set with Fun.
new/0
new() -> set(none())
returns: Returns a new empty set.
Returns a new empty set using the v2 format (a map).
new/1
new(Version::[{version, 2}]) -> set(none())
Version: must be {version, 2}
returns: Returns a new empty set.
Returns a new empty set (only v2 format is supported).
size/1
size(Set) -> non_neg_integer()
Set = set()
Set: the set for which size will be returned
returns: Return the number of elements in Set.
Returns the number of elements in Set.
subtract/2
subtract(Set1, Set2) -> Set3
Set1: the first setSet2: the second set
returns: Returns only the elements of Set1 that are not also elements of Set2.
Return all and only the elements of Set1 which are not also in Set2.
to_list/1
to_list(Set) -> List
Set = set(Element)List = [Element]
Set: the set to be converted to a list
returns: Return the elements in Set as a list.
Returns the elements of Set as a list. The order of the returned elements is
undefined.
union/1
union(SetList) -> Set
SetList: the list of sets
returns: Returns the merged (union) set of the list of sets.
Return the union of the list of sets.
union/2
union(Set1, Set2) -> Set3
Set1: the first setSet2: the second set
returns: Returns the merged (union) set of Set1 and Set2.
Return the union of Set1 and Set2.