Share via


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

Parameters

  • elements
    Type: seq<'T>

    The input sequence.

Return Value

The set containing elements.

Remarks

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.

Example

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 = 
    data.ToCharArray()
    |> 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' 

Platforms

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

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Reference

Collections.Set Module (F#)

Microsoft.FSharp.Collections Namespace (F#)