FSharp.Core


Set Module

Contains operations for working with values of type Set.

Functions and values

Function or value Description

Set.add value set

Full Usage: Set.add value set

Parameters:
    value : 'T - The value to add.
    set : Set<'T> - The input set.

Returns: Set<'T> A new set containing value.

Returns a new set with an element added to the set. No exception is raised if the set already contains the given element.

value : 'T

The value to add.

set : Set<'T>

The input set.

Returns: Set<'T>

A new set containing value.

Set.contains element set

Full Usage: Set.contains element set

Parameters:
    element : 'T - The element to test.
    set : Set<'T> - The input set.

Returns: bool True if element is in set.

Evaluates to "true" if the given element is in the given set.

element : 'T

The element to test.

set : Set<'T>

The input set.

Returns: bool

True if element is in set.

Set.count set

Full Usage: Set.count set

Parameters:
    set : Set<'T> - The input set.

Returns: int The number of elements in the set.

Returns the number of elements in the set. Same as size.

set : Set<'T>

The input set.

Returns: int

The number of elements in the set.

Set.difference set1 set2

Full Usage: Set.difference set1 set2

Parameters:
    set1 : Set<'T> - The first input set.
    set2 : Set<'T> - The set whose elements will be removed from set1.

Returns: Set<'T> The set with the elements of set2 removed from set1.

Returns a new set with the elements of the second set removed from the first.

set1 : Set<'T>

The first input set.

set2 : Set<'T>

The set whose elements will be removed from set1.

Returns: Set<'T>

The set with the elements of set2 removed from set1.

Set.empty

Full Usage: Set.empty

Returns: Set<'T>

The empty set for the type 'T.

Returns: Set<'T>

Set.exists predicate set

Full Usage: Set.exists predicate set

Parameters:
    predicate : 'T -> bool - The function to test set elements.
    set : Set<'T> - The input set.

Returns: bool True if any element of set satisfies predicate.

Tests if any element of the collection satisfies the given predicate. If the input function is predicate and the elements are i0...iN then computes p i0 or ... or p iN.

predicate : 'T -> bool

The function to test set elements.

set : Set<'T>

The input set.

Returns: bool

True if any element of set satisfies predicate.

Set.filter predicate set

Full Usage: Set.filter predicate set

Parameters:
    predicate : 'T -> bool - The function to test set elements.
    set : Set<'T> - The input set.

Returns: Set<'T> The set containing only the elements for which predicate returns true.

Returns a new collection containing only the elements of the collection for which the given predicate returns True.

predicate : 'T -> bool

The function to test set elements.

set : Set<'T>

The input set.

Returns: Set<'T>

The set containing only the elements for which predicate returns true.

Set.fold folder state set

Full Usage: Set.fold folder state set

Parameters:
    folder : 'State -> 'T -> 'State - The accumulating function.
    state : 'State - The initial state.
    set : Set<'T> - The input set.

Returns: 'State The final state.

Applies the given accumulating function to all the elements of the set

folder : 'State -> 'T -> 'State

The accumulating function.

state : 'State

The initial state.

set : Set<'T>

The input set.

Returns: 'State

The final state.

Set.foldBack folder set state

Full Usage: Set.foldBack folder set state

Parameters:
    folder : 'T -> 'State -> 'State - The accumulating function.
    set : Set<'T> - The input set.
    state : 'State - The initial state.

Returns: 'State The final state.

Applies the given accumulating function to all the elements of the set.

folder : 'T -> 'State -> 'State

The accumulating function.

set : Set<'T>

The input set.

state : 'State

The initial state.

Returns: 'State

The final state.

Set.forall predicate set

Full Usage: Set.forall predicate set

Parameters:
    predicate : 'T -> bool - The function to test set elements.
    set : Set<'T> - The input set.

Returns: bool True if all elements of set satisfy predicate.

Tests if all elements of the collection satisfy the given predicate. If the input function is f and the elements are i0...iN and "j0...jN" then computes p i0 && ... && p iN.

predicate : 'T -> bool

The function to test set elements.

set : Set<'T>

The input set.

Returns: bool

True if all elements of set satisfy predicate.

Set.intersect set1 set2

Full Usage: Set.intersect set1 set2

Parameters:
    set1 : Set<'T> - The first input set.
    set2 : Set<'T> - The second input set.

Returns: Set<'T> The intersection of set1 and set2.

Computes the intersection of the two sets.

set1 : Set<'T>

The first input set.

set2 : Set<'T>

The second input set.

Returns: Set<'T>

The intersection of set1 and set2.

Set.intersectMany sets

Full Usage: Set.intersectMany sets

Parameters:
    sets : seq<Set<'T>> - The sequence of sets to intersect.

Returns: Set<'T> The intersection of the input sets.

Computes the intersection of a sequence of sets. The sequence must be non-empty.

sets : seq<Set<'T>>

The sequence of sets to intersect.

Returns: Set<'T>

The intersection of the input sets.

Set.isEmpty set

Full Usage: Set.isEmpty set

Parameters:
    set : Set<'T> - The input set.

Returns: bool True if set is empty.

Returns "true" if the set is empty.

set : Set<'T>

The input set.

Returns: bool

True if set is empty.

Set.isProperSubset set1 set2

Full Usage: Set.isProperSubset set1 set2

Parameters:
    set1 : Set<'T> - The potential subset.
    set2 : Set<'T> - The set to test against.

Returns: bool True if set1 is a proper subset of set2.

Evaluates to "true" if all elements of the first set are in the second, and at least one element of the second is not in the first.

set1 : Set<'T>

The potential subset.

set2 : Set<'T>

The set to test against.

Returns: bool

True if set1 is a proper subset of set2.

Set.isProperSuperset set1 set2

Full Usage: Set.isProperSuperset set1 set2

Parameters:
    set1 : Set<'T> - The potential superset.
    set2 : Set<'T> - The set to test against.

Returns: bool True if set1 is a proper superset of set2.

Evaluates to "true" if all elements of the second set are in the first, and at least one element of the first is not in the second.

set1 : Set<'T>

The potential superset.

set2 : Set<'T>

The set to test against.

Returns: bool

True if set1 is a proper superset of set2.

Set.isSubset set1 set2

Full Usage: Set.isSubset set1 set2

Parameters:
    set1 : Set<'T> - The potential subset.
    set2 : Set<'T> - The set to test against.

Returns: bool True if set1 is a subset of set2.

Evaluates to "true" if all elements of the first set are in the second

set1 : Set<'T>

The potential subset.

set2 : Set<'T>

The set to test against.

Returns: bool

True if set1 is a subset of set2.

Set.isSuperset set1 set2

Full Usage: Set.isSuperset set1 set2

Parameters:
    set1 : Set<'T> - The potential superset.
    set2 : Set<'T> - The set to test against.

Returns: bool True if set1 is a superset of set2.

Evaluates to "true" if all elements of the second set are in the first.

set1 : Set<'T>

The potential superset.

set2 : Set<'T>

The set to test against.

Returns: bool

True if set1 is a superset of set2.

Set.iter action set

Full Usage: Set.iter action set

Parameters:
    action : 'T -> unit - The function to apply to each element.
    set : Set<'T> - The input set.

Applies the given function to each element of the set, in order according to the comparison function.

action : 'T -> unit

The function to apply to each element.

set : Set<'T>

The input set.

Set.map mapping set

Full Usage: Set.map mapping set

Parameters:
    mapping : 'T -> 'U - The function to transform elements of the input set.
    set : Set<'T> - The input set.

Returns: Set<'U> A set containing the transformed elements.

Returns a new collection containing the results of applying the given function to each element of the input set.

mapping : 'T -> 'U

The function to transform elements of the input set.

set : Set<'T>

The input set.

Returns: Set<'U>

A set containing the transformed elements.

Set.maxElement set

Full Usage: Set.maxElement set

Parameters:
    set : Set<'T> - The input set.

Returns: 'T The max value from the set.

Returns the highest element in the set according to the ordering being used for the set.

set : Set<'T>

The input set.

Returns: 'T

The max value from the set.

Set.minElement set

Full Usage: Set.minElement set

Parameters:
    set : Set<'T> - The input set.

Returns: 'T The min value from the set.

Returns the lowest element in the set according to the ordering being used for the set.

set : Set<'T>

The input set.

Returns: 'T

The min value from the set.

Set.ofArray array

Full Usage: Set.ofArray array

Parameters:
    array : 'T[] - The input array.

Returns: Set<'T> A set containing the elements of array.

Builds a set that contains the same elements as the given array.

array : 'T[]

The input array.

Returns: Set<'T>

A set containing the elements of array.

Set.ofList elements

Full Usage: Set.ofList elements

Parameters:
    elements : 'T list - The input list.

Returns: Set<'T> A set containing the elements form the input list.

Builds a set that contains the same elements as the given list.

elements : 'T list

The input list.

Returns: Set<'T>

A set containing the elements form the input list.

Set.ofSeq elements

Full Usage: Set.ofSeq elements

Parameters:
    elements : seq<'T> - The input sequence.

Returns: Set<'T> The set containing elements.

Builds a new collection from the given enumerable object.

elements : seq<'T>

The input sequence.

Returns: Set<'T>

The set containing elements.

Set.partition predicate set

Full Usage: Set.partition predicate set

Parameters:
    predicate : 'T -> bool - The function to test set elements.
    set : Set<'T> - The input set.

Returns: Set<'T> * Set<'T> A pair of sets with the first containing the elements for which predicate returns true and the second containing the elements for which predicate returns false.

Splits the set into two sets containing the elements for which the given predicate returns true and false respectively.

predicate : 'T -> bool

The function to test set elements.

set : Set<'T>

The input set.

Returns: Set<'T> * Set<'T>

A pair of sets with the first containing the elements for which predicate returns true and the second containing the elements for which predicate returns false.

Set.remove value set

Full Usage: Set.remove value set

Parameters:
    value : 'T - The element to remove.
    set : Set<'T> - The input set.

Returns: Set<'T> The input set with value removed.

Returns a new set with the given element removed. No exception is raised if the set doesn't contain the given element.

value : 'T

The element to remove.

set : Set<'T>

The input set.

Returns: Set<'T>

The input set with value removed.

Set.singleton value

Full Usage: Set.singleton value

Parameters:
    value : 'T - The value for the set to contain.

Returns: Set<'T> The set containing value.

The set containing the given element.

value : 'T

The value for the set to contain.

Returns: Set<'T>

The set containing value.

Set.toArray set

Full Usage: Set.toArray set

Parameters:
    set : Set<'T> - The input set.

Returns: 'T[] An ordered array of the elements of set.

Builds an array that contains the elements of the set in order.

set : Set<'T>

The input set.

Returns: 'T[]

An ordered array of the elements of set.

Set.toList set

Full Usage: Set.toList set

Parameters:
    set : Set<'T> - The input set.

Returns: 'T list An ordered list of the elements of set.

Builds a list that contains the elements of the set in order.

set : Set<'T>

The input set.

Returns: 'T list

An ordered list of the elements of set.

Set.toSeq set

Full Usage: Set.toSeq set

Parameters:
    set : Set<'T> - The input set.

Returns: seq<'T> An ordered sequence of the elements of set.

Returns an ordered view of the collection as an enumerable object.

set : Set<'T>

The input set.

Returns: seq<'T>

An ordered sequence of the elements of set.

Set.union set1 set2

Full Usage: Set.union set1 set2

Parameters:
    set1 : Set<'T> - The first input set.
    set2 : Set<'T> - The second input set.

Returns: Set<'T> The union of set1 and set2.

Computes the union of the two sets.

set1 : Set<'T>

The first input set.

set2 : Set<'T>

The second input set.

Returns: Set<'T>

The union of set1 and set2.

Set.unionMany sets

Full Usage: Set.unionMany sets

Parameters:
    sets : seq<Set<'T>> - The sequence of sets to union.

Returns: Set<'T> The union of the input sets.

Computes the union of a sequence of sets.

sets : seq<Set<'T>>

The sequence of sets to union.

Returns: Set<'T>

The union of the input sets.