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 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

Version Information

F# Runtime

Supported in: 2.0, 4.0

Silverlight

Supported in: 3

See Also

Reference

Collections.Set Module (F#)

Microsoft.FSharp.Collections Namespace (F#)