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

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

 

Evaluates to true if all elements of the first set are in the second.

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

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

// Signature:
Set.isSubset : Set<'T> -> Set<'T> -> bool (requires comparison)

// Usage:
Set.isSubset set1 set2

set1

Type: Set<'T>

The potential subset.

set2

Type: Set<'T>

The set to test against.

True if set1 is a subset of set2.

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

Example

The following code illustrates the use of the Set.isSubset function.

let set1 = Set.ofList [ 1 .. 6 ]
let set2 = Set.ofList [ 1 .. 5 ]
let set3 = Set.ofList [ 1 .. 6 ]
let set4 = Set.ofList [ 5 .. 10 ]
printfn "%A is a subset of %A: %b" set2 set1 (Set.isSubset set2 set1)
printfn "%A is a subset of %A: %b" set3 set1 (Set.isSubset set3 set1) 
printfn "%A is a subset of %A: %b" set4 set1 (Set.isSubset set4 set1) 

Output

set [1; 2; 3; 4; 5] is a subset of set [1; 2; 3; 4; 5; 6]: true
set [1; 2; 3; 4; 5; 6] is a subset of set [1; 2; 3; 4; 5; 6]: true
set [5; 6; 7; 8; 9; 10] is a subset of set [1; 2; 3; 4; 5; 6]: false

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

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

Show:
© 2016 Microsoft