Set Module
Contains operations for working with values of type Set.
Functions and values
| Function or value |
Description
|
|
Returns a new set with an element added to the set. No exception is raised if the set already contains the given element. This is an O(log n) operation, where n is the number of elements in the set.
Example
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]
|
|
Evaluates to "true" if the given element is in the given set. This is an O(log n) operation, where n is the number of elements in the set.
Example
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
|
|
Returns the number of elements in the set. Same as This is an O(n) operation.
Example
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
|
|
Returns a new set with the elements of the second set removed from the first. This is an O(m log n) operation, where m is the number of elements in the second set and n is the number of elements in the first set.
Example
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]
|
The empty set for the type 'T. This is an O(1) operation.
Example
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
Evaluates to val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int set [ ].
|
|
|
Tests if any element of the collection satisfies the given predicate.
If the input function is This is an O(n) operation, where n is the number of elements in the set.
Example
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
|
|
Returns a new collection containing only the elements of the collection for which the given predicate returns True. This is an O(n log n) operation, where n is the number of elements in the set.
Example
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]
|
Full Usage:
Set.fold folder state set
Parameters:
'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 This is an O(n) operation, where n is the number of elements in the set.
Example
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]
|
Full Usage:
Set.foldBack folder set state
Parameters:
'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. This is an O(n) operation, where n is the number of elements in the set.
Example
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]
|
|
Tests if all elements of the collection satisfy the given predicate.
If the input function is This is an O(n) operation, where n is the number of elements in the set.
Example
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
|
|
Computes the intersection of the two sets. This is an O(m log n) operation, where m is the number of elements in the first set and n is the number of elements in the second set.
Example
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]
|
|
Computes the intersection of a sequence of sets. The sequence must be non-empty. This is an O((k-1) * m log n) operation, where k is the number of sets in the sequence, m is the size of each set, and n is the size of the accumulated intersection.
Example
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"]
|
|
Returns "true" if the set is empty. This is an O(1) operation.
Example
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
|
|
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.
This is an O(m log n) operation, where m is the number of elements in
Example
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
|
|
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.
This is an O(m log n) operation, where m is the number of elements in
Example
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
|
|
Evaluates to "true" if all elements of the first set are in the second
This is an O(m log n) operation, where m is the number of elements in
Example
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
|
|
Evaluates to "true" if all elements of the second set are in the first.
This is an O(m log n) operation, where m is the number of elements in
Example
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
|
|
Applies the given function to each element of the set, in order according to the comparison function. This is an O(n) operation, where n is the number of elements in the set. Example
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
|
|
Returns a new collection containing the results of applying the given function to each element of the input set. This is an O(n log n) operation, where n is the number of elements in the set.
Example
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]
|
Full Usage:
Set.maxElement set
Parameters:
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. This is an O(log n) operation, where n is the number of elements in the set.
Example
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
|
Full Usage:
Set.minElement set
Parameters:
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. This is an O(log n) operation, where n is the number of elements in the set.
Example
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
|
|
Builds a set that contains the same elements as the given array. This is an O(n log n) operation, where n is the number of elements in the array.
Example
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"
|
|
Builds a set that contains the same elements as the given list. This is an O(n log n) operation, where n is the number of elements in the list.
Example
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"
|
|
Builds a new collection from the given enumerable object. This is an O(n log n) operation, where n is the number of elements in the sequence.
Example
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"
|
Splits the set into two sets containing the elements for which the given predicate returns true and false respectively. This is an O(n log n) operation, where n is the number of elements in the set.
Example
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])
|
|
|
Returns a new set with the given element removed. No exception is raised if the set doesn't contain the given element. This is an O(log n) operation, where n is the number of elements in the set.
Example
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]
|
Full Usage:
Set.singleton value
Parameters:
'T
-
The value for the set to contain.
Returns: Set<'T>
The set containing value.
|
The set containing the given element. This is an O(1) operation.
Example
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 ].
|
|
Builds an array that contains the elements of the set in order. This is an O(n) operation, where n is the number of elements in the set.
Example
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
|
|
Builds a list that contains the elements of the set in order. This is an O(n) operation, where n is the number of elements in the set.
Example
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"
|
|
Returns an ordered view of the collection as an enumerable object. This is an O(1) operation.
Example
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]
|
|
Computes the union of the two sets. This is an O(m log n) operation, where m is the number of elements in the first set and n is the number of elements in the second set.
Example
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]
|
|
Computes the union of a sequence of sets. This is an O(k * m log n) operation, where k is the number of sets in the sequence, m is the average size of each set, and n is the size of the accumulated union.
Example
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"]
|
FSharp.Core