Share via


Set.( + )<'T> Method (F#)

Compute the union of the two sets.

Namespace/Module Path: Microsoft.FSharp.Collections

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

// Signature:
static member ( + ) : Set<'T> * Set<'T> -> Set<'T> (requires comparison)

// Usage:
set1 + set2

Parameters

  • set1
    Type: Set<'T>

    The first input set.

  • set2
    Type: Set<'T>

    The second input set.

Return Value

The union of the two input sets.

Example

The following code illustrates the use of the + and - operators on sets.

let set1 = Set.ofList [ 1 .. 3 ]
let set2 = Set.ofList [ 4 .. 6 ]

let set3 = set1 + set2
let set4 = set3 - set1
let set5 = set3 - set2

printfn "set1: %A" set1
printfn "set2: %A" set2
printfn "set3 = set1 + set2: %A" set3
printfn "set3 - set1: %A" set4
printfn "set3 - set2: %A" set5

Output

set1: set [1; 2; 3]
set2: set [4; 5; 6]
set3 = set1 + set2: set [1; 2; 3; 4; 5; 6]
set3 - set1: set [4; 5; 6]
set3 - set2: set [1; 2; 3]

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<'T> Class (F#)

Microsoft.FSharp.Collections Namespace (F#)