Set.filter<'T> Function (F#)
Returns a new collection containing only the elements of the collection for which the given predicate returns true.
Namespace/Module Path: Microsoft.FSharp.Collections.Set
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature:
Set.filter : ('T -> bool) -> Set<'T> -> Set<'T> (requires comparison)
// Usage:
Set.filter predicate set
Parameters
Return Value
The set containing only the elements for which predicate returns true.
Remarks
This function is named Filter 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.filter function.
let set1 = Set.ofList [ 1 .. 10]
|> Set.filter (fun elem -> elem % 2 = 0)
printfn "%A" set1
Output
set [2; 4; 6; 8; 10]
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