Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Latest commit

 

History

History
69 lines (43 loc) · 1.76 KB

File metadata and controls

69 lines (43 loc) · 1.76 KB
title Option.filter<'T> Function (F#)
description Option.filter<'T> Function (F#)
keywords visual f#, f#, functional programming
author eriawan
manager danielfe
ms.date 07/01/2016
ms.topic language-reference
ms.prod visual-studio-dev14
ms.technology devlang-fsharp
ms.assetid ff36174c-0820-47e4-b7ce-6fa93f19bcb5

Option.filter<'T> Function (F#)

Evaluates whether the value contained in the option should remain, or be filtered out.

Namespace/Module Path: Microsoft.FSharp.Core.Option

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

Syntax

// Signature:
filter : ('T -> bool) -> option:'T option -> 'T option

// Usage:
filter predicate option

Parameters

predicate Type: 'T ->bool

A function that evaluates whether the value contained in the option should remain, or be filtered out.

option Type: 'T option

The input option.

Return Value

The input option if it has a value and the predicate evaluates to true for this value; otherwise, None.

Remarks

The expression Option.filter f inp evaluates to match inp with Some x when f x -> inp | _ -> None.

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.

Platforms

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

Version Information

F# Core Library Versions

Supported in: 4.0, Portable

See Also

Core.Option Module (F#)

Microsoft.FSharp.Core Namespace (F#)