Export (0) Print
Expand All

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

Returns a new set with the elements of the second set removed from the first.

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

set1

Type: Set<'T>

The first input set.

set2

Type: Set<'T>

The second input set.

A set containing elements of the first set that are not contained in the second set.

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]

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

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

Show:
© 2014 Microsoft