Header menu logo 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.

Example

 let set = Set.empty.Add(1).Add(1).Add(2)
 printfn $"The new set is: {set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The new set is: set [1; 2]

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.

Example

 let set = Set.empty.Add(2).Add(3)
 printfn $"Does the set contain 1? {set.Contains(1))}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
member Set.Contains: value: 'T -> bool
The sample evaluates to the following output: Does the set contain 1? false

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"The set has {set.Count} elements"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
property Set.Count: int with get
The sample evaluates to the following output: The set has 3 elements

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.

Example

 let set1 = Set.empty.Add(1).Add(2).Add(3)
 let set2 = Set.empty.Add(2).Add(3).Add(4)
 printfn $"The difference of {set1} and {set2} is {Set.difference set1 set2}"
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The difference of set [1; 2; 3] and set [2; 3; 4] is set [1]

Set.empty

Full Usage: Set.empty

Returns: Set<'T>

The empty set for the type 'T.

Returns: Set<'T>
Example

 Set.empty<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
Evaluates to set [ ].

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"Does the set contain 1? {Set.exists (fun x -> x = 1) set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val exists: predicate: ('T -> bool) -> set: Set<'T> -> bool (requires comparison)
val x: int
The sample evaluates to the following output: Does the set contain 1? true

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3).Add(4)
 printfn $"The set with even numbers is {Set.filter (fun x -> x % 2 = 0) set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val filter: predicate: ('T -> bool) -> set: Set<'T> -> Set<'T> (requires comparison)
val x: int
The sample evaluates to the following output: The set with even numbers is set [2; 4]

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"The sum of the set is {Set.fold (+) 0 set}"
 printfn $"The product of the set is {Set.fold (*) 1 set}"
 printfn $"The reverse of the set is {Set.fold (fun x y -> y :: x) [] set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val fold<'T,'State (requires comparison)> : folder: ('State -> 'T -> 'State) -> state: 'State -> set: Set<'T> -> 'State (requires comparison)
val x: int list
val y: int
The sample evaluates to the following output: The sum of the set is 6 The product of the set is 6 The reverse of the set is [3; 2; 1]

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"The sum of the set is {Set.foldBack (+) set 0}"
 printfn $"The set is {Set.foldBack (fun x acc -> x :: acc) set []}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val foldBack: folder: ('T -> 'State -> 'State) -> set: Set<'T> -> state: 'State -> 'State (requires comparison)
val x: int
val acc: int list
The sample evaluates to the following output: The sum of the set is 6 The set is [1; 2; 3]

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"Does the set contain even numbers? {Set.forall (fun x -> x % 2 = 0) set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val forall: predicate: ('T -> bool) -> set: Set<'T> -> bool (requires comparison)
val x: int
The sample evaluates to the following output: Does the set contain even numbers? false

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.

Example

 let set1 = Set.empty.Add(1).Add(2).Add(3)
 let set2 = Set.empty.Add(2).Add(3).Add(4)
 printfn $"The intersection of {set1} and {set2} is {Set.intersect set1 set2}"
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The intersection of set [1; 2; 3] and set [2; 3; 4] is set [2; 3]

Set.intersectMany sets

Full Usage: Set.intersectMany sets

Parameters:
    sets : Set<'T> seq - 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 : Set<'T> seq

The sequence of sets to intersect.

Returns: Set<'T>

The intersection of the input sets.

Example

 let headersByFile = seq{
 yield [ "id"; "name"; "date"; "color" ]
 yield [ "id"; "age"; "date" ]
 yield [ "id"; "sex"; "date"; "animal" ]
 }
 headersByFile
 |> Seq.map Set.ofList
 |> Set.intersectMany
 |> printfn "The intersection of %A is %A" headersByFile
val headersByFile: string list seq
Multiple items
val seq: sequence: 'T seq -> 'T seq

--------------------
type 'T seq = System.Collections.Generic.IEnumerable<'T>
module Seq from Microsoft.FSharp.Collections
val map: mapping: ('T -> 'U) -> source: 'T seq -> 'U seq
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val ofList: elements: 'T list -> Set<'T> (requires comparison)
val intersectMany: sets: Set<'T> seq -> Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The intersection of seq [["id"; "name"; "date"; "color"]; ["id"; "age"; "date"]; ["id"; "sex"; "date"; "animal"]] is set ["date"; "id"]

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.

Example

 let set = Set.empty.Add(2).Add(3)
 printfn $"Is the set empty? {set.IsEmpty}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
property Set.IsEmpty: bool with get
The sample evaluates to the following output: Is the set empty? false

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.

Example

 let set1 = Set.empty.Add(1).Add(2).Add(3)
 let set2 = Set.empty.Add(1).Add(2).Add(3).Add(4)
 printfn $"Is {set1} a proper subset of {set2}? {Set.isProperSubset set1 set2}"
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: Is set [1; 2; 3] a proper subset of set [1; 2; 3; 4]? true

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.

Example

 let set1 = Set.empty.Add(1).Add(2).Add(3)
 let set2 = Set.empty.Add(1).Add(2).Add(3).Add(4)
 printfn $"Is {set1} a proper superset of {set2}? {Set.isProperSuperset set1 set2}"
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: Is set [1; 2; 3] a proper superset of set [1; 2; 3; 4]? false

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.

Example

 let set1 = Set.empty.Add(1).Add(2).Add(3)
 let set2 = Set.empty.Add(1).Add(2).Add(3).Add(4)
 printfn $"Is {set1} a subset of {set2}? {Set.isSubset set1 set2}"
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: Is set [1; 2; 3] a subset of set [1; 2; 3; 4]? true

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.

Example

 let set1 = Set.empty.Add(1).Add(2).Add(3)
 let set2 = Set.empty.Add(1).Add(2).Add(3).Add(4)
 printfn $"Is {set1} a superset of {set2}? {Set.isSuperset set1 set2}"
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: Is set [1; 2; 3] a superset of set [1; 2; 3; 4]? false

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 Set.iter (fun x -> printfn $"The set contains {x}") set
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val iter: action: ('T -> unit) -> set: Set<'T> -> unit (requires comparison)
val x: int
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The set contains 1 The set contains 2 The set contains 3

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"The set with doubled values is {Set.map (fun x -> x * 2) set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val map: mapping: ('T -> 'U) -> set: Set<'T> -> Set<'U> (requires comparison and comparison)
val x: int
The sample evaluates to the following output: The set with doubled values is set [2; 4; 6]

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"The min element of {set} is {Set.minElement set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The max element of set [1; 2; 3] is 3

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"The min element of {set} is {Set.minElement set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The min element of set [1; 2; 3] is 1

Set.ofArray array

Full Usage: Set.ofArray array

Parameters:
    array : 'T array - 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 array

The input array.

Returns: Set<'T>

A set containing the elements of array.

Example

 let set = Set.ofArray [|1, 2, 3|]
 printfn $"The set is {set} and type is {set.GetType().Name}"
val set: Set<int * int * int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val ofArray: array: 'T array -> Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The set is set [(1, 2, 3)] and type is "FSharpSet`1"

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.

Example

 let set = Set.ofList [1, 2, 3]
 printfn $"The set is {set} and type is {set.GetType().Name}"
val set: Set<int * int * int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val ofList: elements: 'T list -> Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The set is set [(1, 2, 3)] and type is "FSharpSet`1"

Set.ofSeq elements

Full Usage: Set.ofSeq elements

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

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

Builds a new collection from the given enumerable object.

elements : 'T seq

The input sequence.

Returns: Set<'T>

The set containing elements.

Example

 let set = Set.ofSeq [1, 2, 3]
 printfn $"The set is {set} and type is {set.GetType().Name}"
val set: Set<int * int * int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val ofSeq: elements: 'T seq -> Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The set is set [(1, 2, 3)] and type is "FSharpSet`1"

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3).Add(4)
 printfn $"The set with even numbers is {Set.partition (fun x -> x % 2 = 0) set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val partition: predicate: ('T -> bool) -> set: Set<'T> -> Set<'T> * Set<'T> (requires comparison)
val x: int
The sample evaluates to the following output: The partitioned sets are: (set [2; 4], set [1; 3])

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 printfn $"The set without 1 is {Set.remove 1 set}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val remove: value: 'T -> set: Set<'T> -> Set<'T> (requires comparison)
The sample evaluates to the following output: The set without 1 is set [2; 3]

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.

Example

 Set.singleton 7
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val singleton: value: 'T -> Set<'T> (requires comparison)
Evaluates to set [ 7 ].

Set.toArray set

Full Usage: Set.toArray set

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

Returns: 'T array 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 array

An ordered array of the elements of set.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 let array = Set.toArray set
 printfn$ "The set is {set} and type is {array.GetType().Name}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
Multiple items
val array: int array

--------------------
type 'T array = 'T array
val toArray: set: Set<'T> -> 'T array (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The set is [|1; 2; 3|] and type is System.Int32 array

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.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 let list = Set.toList set
 printfn $"The set is {list} and type is {list.GetType().Name}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
Multiple items
val list: int list

--------------------
type 'T list = List<'T>
val toList: set: Set<'T> -> 'T list (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The set is [1; 2; 3] and type is "FSharpList`1"

Set.toSeq set

Full Usage: Set.toSeq set

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

Returns: 'T seq 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: 'T seq

An ordered sequence of the elements of set.

Example

 let set = Set.empty.Add(1).Add(2).Add(3)
 let seq = Set.toSeq set
 printfn $"The set is {set} and type is {seq.GetType().Name}"
val set: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
Multiple items
val seq: int seq

--------------------
type 'T seq = System.Collections.Generic.IEnumerable<'T>
val toSeq: set: Set<'T> -> 'T seq (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: he set is set [1; 2; 3] and type is Microsoft.FSharp.Collections.FSharpSet`1[System.Int32]

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.

Example

 let set1 = Set.empty.Add(1).Add(2).Add(3)
 let set2 = Set.empty.Add(2).Add(3).Add(4)
 printfn $"The union of {set1} and {set2} is {(Set.union set1 set2)}"
val set1: Set<int>
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val empty<'T (requires comparison)> : Set<'T> (requires comparison)
val set2: Set<int>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
val union: set1: Set<'T> -> set2: Set<'T> -> Set<'T> (requires comparison)
The sample evaluates to the following output: The union of set [1; 2; 3] and set [2; 3; 4] is set [1; 2; 3; 4]

Set.unionMany sets

Full Usage: Set.unionMany sets

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

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

Computes the union of a sequence of sets.

sets : Set<'T> seq

The sequence of sets to union.

Returns: Set<'T>

The union of the input sets.

Example

 let headersByFile = seq{
 yield [ "id"; "name"; "date"; "color" ]
 yield [ "id"; "age"; "date" ]
 yield [ "id"; "sex"; "date"; "animal" ]
 }
 headersByFile
 |> Seq.map Set.ofList
 |> Set.intersectMany
 |> printfn "The intersection of %A is %A" headersByFile
val headersByFile: string list seq
Multiple items
val seq: sequence: 'T seq -> 'T seq

--------------------
type 'T seq = System.Collections.Generic.IEnumerable<'T>
module Seq from Microsoft.FSharp.Collections
val map: mapping: ('T -> 'U) -> source: 'T seq -> 'U seq
Multiple items
module Set from Microsoft.FSharp.Collections

--------------------
type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: obj -> bool ...

--------------------
new: elements: 'T seq -> Set<'T>
val ofList: elements: 'T list -> Set<'T> (requires comparison)
val intersectMany: sets: Set<'T> seq -> Set<'T> (requires comparison)
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
The sample evaluates to the following output: The union of seq [["id"; "name"; "date"; "color"]; ["id"; "age"; "date"]; ["id"; "sex"; "date"; "animal"]] is set ["age"; "animal"; "color"; "date"; "id"; "name"; "sex"]

Type something to start searching.