Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Set.ofSeq<'T> Function (F#)

Creates a new collection from the given enumerable object.

Namespace/Module Path: Microsoft.FSharp.Collections.Set

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
Set.ofSeq : seq<'T> -> Set<'T> (requires comparison)

// Usage:
Set.ofSeq elements


Type: seq<'T>

The input sequence.

The set containing elements.

This function is named OfSeq in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

The following example demonstrates how to create a set from a sequence by using Set.ofSeq.

let data = "The quick brown fox jumps over the lazy dog"  
let set = 
    |> Set.ofSeq
for c in set do 
    printf "'%c' " c 
printfn ""
' ' 'T' 'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' 'x' 'y' 'z' 

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

© 2015 Microsoft